stop using __u32 etc. uint32_t is there for a reason
[oweals/busybox.git] / init / init.c
index 607a1f3e08e724a01dcf8a57e2f7adb7582c186e..2e8ca3ca83d35d02b44f6c0acf386bfb2d7275a2 100644 (file)
@@ -173,7 +173,7 @@ static void loop_forever(void)
 #if ENABLE_DEBUG_INIT
 #define messageD message
 #else
-#define messageD(...)  do {;} while(0);
+#define messageD(...)  do {} while (0)
 #endif
 static void message(int device, const char *fmt, ...)
        __attribute__ ((format(printf, 2, 3)));
@@ -195,7 +195,7 @@ static void message(int device, const char *fmt, ...)
        /* Log the message to syslogd */
        if (device & LOG) {
                /* don`t out "\r\n" */
-               openlog(bb_applet_name, 0, LOG_DAEMON);
+               openlog(applet_name, 0, LOG_DAEMON);
                syslog(LOG_INFO, "%s", msg + 1);
                closelog();
        }
@@ -211,7 +211,7 @@ static void message(int device, const char *fmt, ...)
        if (log_fd < 0) {
                if ((log_fd = device_open(log_console, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0) {
                        log_fd = -2;
-                       bb_error_msg("Bummer, can't write to log on %s!", log_console);
+                       bb_error_msg("bummer, can't write to log on %s!", log_console);
                        device = CONSOLE;
                } else {
                        fcntl(log_fd, F_SETFD, FD_CLOEXEC);
@@ -232,7 +232,7 @@ static void message(int device, const char *fmt, ...)
 #if ENABLE_DEBUG_INIT
                /* all descriptors may be closed */
                } else {
-                       bb_error_msg("Bummer, can't print: ");
+                       bb_error_msg("bummer, can't print: ");
                        va_start(arguments, fmt);
                        vfprintf(stderr, fmt, arguments);
                        va_end(arguments);
@@ -534,7 +534,7 @@ static pid_t run(const struct init_action *a)
                                                "(pid %d, terminal %s)\n",
                                          cmdpath, getpid(), a->terminal);
                        full_write(1, press_enter, sizeof(press_enter) - 1);
-                       while(read(0, &c, 1) == 1 && c != '\n')
+                       while (read(0, &c, 1) == 1 && c != '\n')
                                ;
                }
 #endif
@@ -561,7 +561,7 @@ static pid_t run(const struct init_action *a)
                execv(cmdpath, cmd);
 
                /* We're still here?  Some error happened. */
-               message(LOG | CONSOLE, "Bummer, could not run '%s': %m", cmdpath);
+               message(LOG | CONSOLE, "Bummer, cannot run '%s': %m", cmdpath);
                _exit(-1);
        }
        sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -982,7 +982,7 @@ int init_main(int argc, char **argv)
 #if !ENABLE_DEBUG_INIT
        /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */
        if (getpid() != 1 &&
-               (!ENABLE_FEATURE_INITRD || !strstr(bb_applet_name, "linuxrc")))
+               (!ENABLE_FEATURE_INITRD || !strstr(applet_name, "linuxrc")))
        {
                bb_show_usage();
        }
@@ -1021,7 +1021,7 @@ int init_main(int argc, char **argv)
        {
                const char * const *e;
                /* Make sure environs is set to something sane */
-               for(e = environment; *e; e++)
+               for (e = environment; *e; e++)
                        putenv((char *) *e);
        }
 
@@ -1035,7 +1035,7 @@ int init_main(int argc, char **argv)
                struct sysinfo info;
 
                if (!sysinfo(&info) &&
-                       (info.mem_unit ? : 1) * (long long)info.totalram < MEGABYTE)
+                       (info.mem_unit ? : 1) * (long long)info.totalram < 1024*1024)
                {
                        message(CONSOLE,"Low memory: forcing swapon.");
                        /* swapon -a requires /proc typically */
@@ -1047,8 +1047,9 @@ int init_main(int argc, char **argv)
        }
 
        /* Check if we are supposed to be in single user mode */
-       if (argc > 1 && (!strcmp(argv[1], "single") ||
-                                        !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) {
+       if (argc > 1
+        && (!strcmp(argv[1], "single") || !strcmp(argv[1], "-s") || LONE_CHAR(argv[1], '1'))
+       ) {
                /* Start a shell on console */
                new_init_action(RESPAWN, bb_default_login_shell, "");
        } else {
@@ -1125,7 +1126,7 @@ int init_main(int argc, char **argv)
                                }
                        }
                        /* see if anyone else is waiting to be reaped */
-                       wpid = waitpid (-1, NULL, WNOHANG);
+                       wpid = waitpid(-1, NULL, WNOHANG);
                }
        }
 }