OSDN Git Service

wtmp code: style fixes, no code changes
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 5 Sep 2009 21:30:57 +0000 (23:30 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 5 Sep 2009 21:30:57 +0000 (23:30 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libc/misc/utmp/wtent.c
libutil/logwtmp.c

index b7a5817..e73d99f 100644 (file)
 #include <sys/file.h>
 
 #if 0
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-/* libc_hidden_proto(updwtmp) */
-#endif
-/* libc_hidden_proto(open) */
-/* libc_hidden_proto(write) */
-/* libc_hidden_proto(close) */
-/* libc_hidden_proto(lockf) */
-/* libc_hidden_proto(gettimeofday) */
-
-#if 0
 /* This is enabled in uClibc/libutil/logwtmp.c */
 void logwtmp (const char *line, const char *name, const char *host)
 {
     struct utmp lutmp;
-    memset (&(lutmp), 0, sizeof (struct utmp));
+    memset(&lutmp, 0, sizeof(lutmp));
 
-    lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS;
-    lutmp.ut_pid = __getpid();
+    lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS;
+    lutmp.ut_pid = getpid();
     strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
     strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
     strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
     gettimeofday(&(lutmp.ut_tv), NULL);
 
-    updwtmp(_PATH_WTMP, &(lutmp));
+    updwtmp(_PATH_WTMP, &lutmp);
 }
 #endif
 
@@ -47,10 +36,10 @@ void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
 {
     int fd;
 
-    fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
+    fd = open(wtmp_file, O_APPEND | O_WRONLY);
     if (fd >= 0) {
-       if (lockf(fd, F_LOCK, 0)==0) {
-           write(fd, (const char *) lutmp, sizeof(struct utmp));
+       if (lockf(fd, F_LOCK, 0) == 0) {
+           write(fd, lutmp, sizeof(*lutmp));
            lockf(fd, F_ULOCK, 0);
            close(fd);
        }
index 0845b50..2a6f28a 100644 (file)
 #include <fcntl.h>
 #include <sys/file.h>
 
-
-void logwtmp (const char *line, const char *name, const char *host)
+void logwtmp(const char *line, const char *name, const char *host)
 {
     struct utmp lutmp;
-    memset (&(lutmp), 0, sizeof (struct utmp));
+    memset(&lutmp, 0, sizeof(lutmp));
 
-    lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS;
+    lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS;
     lutmp.ut_pid = getpid();
     strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
     strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
     strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
 #if !defined __WORDSIZE_COMPAT32 || __WORDSIZE_COMPAT32 == 0
-    gettimeofday(&(lutmp.ut_tv), NULL);
+    gettimeofday(&lutmp.ut_tv, NULL);
 #else
     {
       struct timeval tv;
-      gettimeofday (&tv, NULL);
+      gettimeofday(&tv, NULL);
       lutmp.ut_tv.tv_sec = tv.tv_sec;
       lutmp.ut_tv.tv_usec = tv.tv_usec;
     }
 #endif
 
-    updwtmp(_PATH_WTMP, &(lutmp));
+    updwtmp(_PATH_WTMP, &lutmp);
 }
 
 #if 0
 /* This is enabled in uClibc/libc/misc/utmp/wtent.c */
-extern void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
+void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
 {
     int fd;
 
-    fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
+    fd = open(wtmp_file, O_APPEND | O_WRONLY);
     if (fd >= 0) {
-       if (lockf(fd, F_LOCK, 0)==0) {
-           write(fd, (const char *) lutmp, sizeof(struct utmp));
+       if (lockf(fd, F_LOCK, 0) == 0) {
+           write(fd, lutmp, sizeof(*lutmp));
            lockf(fd, F_ULOCK, 0);
            close(fd);
        }