On Wednesday 28 January 2009 06:33, Rob Landley wrote:
> A quick glance at the code showed things like:
>
> #if ENABLE_FEATURE_USE_INITTAB
> signal(SIGHUP, reload_signal);
> #else
> signal(SIGHUP, SIG_IGN);
> #endif
I reviewed the code and found two intances of code I can simplify a bit.
> When the whole point of ENABLE macros (defined to 0 or 1) is so you can
> instead use code like:
>
> if (ENABLE_FEATURE_USE_INITTAB) signal(SIGHUP, reload_signal);
> else signal(SIGHUP, SIG_IGN);
>
> Or even:
>
> signal(SIGHUP, ENABLE_FEATURE_USE_INITTAB ? reload_signal : SIG_IGN);
But then I need to add this:
}
+#else
+void reload_signal(int sig);
#endif
Anyway. Please review attached patch.
--
vda
diff -d -urpN busybox.1/init/init.c busybox.2/init/init.c
--- busybox.1/init/init.c 2009-01-08 03:46:37.000000000 +0100
+++ busybox.2/init/init.c 2009-01-29 00:50:31.000000000 +0100
@@ -64,13 +64,7 @@ static const char *log_console = VC_5;
enum {
L_LOG = 0x1,
L_CONSOLE = 0x2,
-
-#if ENABLE_FEATURE_EXTRA_QUIET
- MAYBE_CONSOLE = 0x0,
-#else
- MAYBE_CONSOLE = L_CONSOLE,
-#endif
-
+ MAYBE_CONSOLE = L_CONSOLE * !ENABLE_FEATURE_EXTRA_QUIET,
#ifndef RB_HALT_SYSTEM
RB_HALT_SYSTEM = 0xcdef0123, /* FIXME: this overflows enum */
RB_ENABLE_CAD = 0x89abcdef,
@@ -775,6 +769,8 @@ static void reload_signal(int sig UNUSED
}
run_actions(RESPAWN | ASKFIRST);
}
+#else
+void reload_signal(int sig);
#endif
int init_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -901,11 +897,7 @@ int init_main(int argc UNUSED_PARAM, cha
run_actions(ONCE);
/* Redefine SIGHUP to reread /etc/inittab */
-#if ENABLE_FEATURE_USE_INITTAB
- signal(SIGHUP, reload_signal);
-#else
- signal(SIGHUP, SIG_IGN);
-#endif
+ signal(SIGHUP, ENABLE_FEATURE_USE_INITTAB ? reload_signal : SIG_IGN);
/* Now run the looping stuff for the rest of forever */
while (1) {
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox