diff options
author | Denys Vlasenko | 2009-10-11 02:15:49 +0200 |
---|---|---|
committer | Denys Vlasenko | 2009-10-11 02:15:49 +0200 |
commit | 8c66a9d07a771424e79a56698cdad7f4e4de89ac (patch) | |
tree | 17dcaf6c118495bc8be1ce3f6a8d6d10e86dbc39 | |
parent | e7670ff81d01d06f8f27ffb3b6e6d5e6f92c8f74 (diff) | |
download | busybox-8c66a9d07a771424e79a56698cdad7f4e4de89ac.zip busybox-8c66a9d07a771424e79a56698cdad7f4e4de89ac.tar.gz |
hush: shrink $RANDOM support
function old new delta
get_local_var_value 104 125 +21
hush_main 1024 983 -41
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/shell/hush.c b/shell/hush.c index ef40e5a..d105029 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1318,8 +1318,11 @@ static const char *get_local_var_value(const char *name) return utoa(G.root_ppid); // bash compat: UID? EUID? #if ENABLE_HUSH_RANDOM_SUPPORT - if (strcmp(name, "RANDOM") == 0) + if (strcmp(name, "RANDOM") == 0) { + if (G.random_gen.galois_LFSR == 0) + INIT_RANDOM_T(&G.random_gen, G.root_pid, monotonic_us()); return utoa(next_random(&G.random_gen)); + } #endif return NULL; } @@ -6605,9 +6608,6 @@ int hush_main(int argc, char **argv) if (!G.root_pid) { G.root_pid = getpid(); G.root_ppid = getppid(); -#if ENABLE_HUSH_RANDOM_SUPPORT - INIT_RANDOM_T(&G.random_gen, G.root_pid, monotonic_us()); -#endif } G.global_argv = argv + optind; G.global_argc = argc - optind; @@ -6696,9 +6696,6 @@ int hush_main(int argc, char **argv) G.root_pid = getpid(); G.root_ppid = getppid(); } -#if ENABLE_HUSH_RANDOM_SUPPORT - INIT_RANDOM_T(&G.random_gen, G.root_pid, monotonic_us()); -#endif /* If we are login shell... */ if (argv[0] && argv[0][0] == '-') { |