udhcpc: do not test for srand init, just do it at the start
function old new delta udhcpc_main 2855 2867 +12 static.initialized 1 - -1 client_background 32 31 -1 perform_release 124 122 -2 random_xid 38 - -38 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 1/2 up/down: 12/-42) Total: -30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
501e35c474
commit
8d1144565f
@ -64,14 +64,8 @@ static smallint state;
|
|||||||
|
|
||||||
|
|
||||||
/* Create a random xid */
|
/* Create a random xid */
|
||||||
static uint32_t random_xid(void)
|
static ALWAYS_INLINE uint32_t random_xid(void)
|
||||||
{
|
{
|
||||||
static smallint initialized;
|
|
||||||
|
|
||||||
if (!initialized) {
|
|
||||||
srand(monotonic_us());
|
|
||||||
initialized = 1;
|
|
||||||
}
|
|
||||||
return rand();
|
return rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,15 +637,14 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
bb_sanitize_stdio();
|
bb_sanitize_stdio();
|
||||||
/* Equivalent of doing a fflush after every \n */
|
/* Equivalent of doing a fflush after every \n */
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
|
|
||||||
/* Create pidfile */
|
/* Create pidfile */
|
||||||
write_pidfile(client_config.pidfile);
|
write_pidfile(client_config.pidfile);
|
||||||
|
|
||||||
/* Goes to stdout (unless NOMMU) and possibly syslog */
|
/* Goes to stdout (unless NOMMU) and possibly syslog */
|
||||||
bb_info_msg("%s (v"BB_VER") started", applet_name);
|
bb_info_msg("%s (v"BB_VER") started", applet_name);
|
||||||
|
|
||||||
/* Set up the signal pipe */
|
/* Set up the signal pipe */
|
||||||
udhcp_sp_setup();
|
udhcp_sp_setup();
|
||||||
|
/* We want random_xid to be random... */
|
||||||
|
srand(monotonic_us());
|
||||||
|
|
||||||
state = INIT_SELECTING;
|
state = INIT_SELECTING;
|
||||||
udhcp_run_script(NULL, "deconfig");
|
udhcp_run_script(NULL, "deconfig");
|
||||||
@ -681,7 +674,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
tv.tv_sec = timeout - already_waited_sec;
|
tv.tv_sec = timeout - already_waited_sec;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
retval = 0; /* If we already timed out, fall through, else... */
|
retval = 0;
|
||||||
|
/* If we already timed out, fall through with retval = 0, else... */
|
||||||
if ((int)tv.tv_sec > 0) {
|
if ((int)tv.tv_sec > 0) {
|
||||||
timestamp_before_wait = (unsigned)monotonic_sec();
|
timestamp_before_wait = (unsigned)monotonic_sec();
|
||||||
log1("Waiting on select...");
|
log1("Waiting on select...");
|
||||||
|
Loading…
Reference in New Issue
Block a user