use C89 random functions in conf.c
PATCH 1/1 use C89 random functions in conf.c
Hi,
rand and srand functions conform also to C89 in addition to POSIX.1-2001, which makes them a bit more portable (work also on MinGW host). Linux man page also says:
"The versions of rand() and srand() in the Linux C Library use the same random number generator as random() and srandom()".
Once there, sort includes and remove leading whitespace.
* Use C89 conformant functions rand() and srand()
scripts/kconfig/conf.c +6 -6
@@ -4,11 +4,11 @@*/ #include <ctype.h> -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <unistd.h> #include <time.h> +#include <unistd.h> #include <sys/stat.h> #define LKC_DIRECT_LINK
@@ -160,7 +160,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) }case set_random:do { - val = (tristate)(random () %3 ); + val = (tristate)(rand () %3 ); }while (!sym_tristate_within_range (sym, val));switch (val) {case no: line[0 ] ='n' ;break ;
@@ -374,7 +374,7 @@ static int conf_choice(struct menu *menu)continue ;break ;case set_random: - def = (random () % cnt) +1 ; + def = (rand () % cnt) +1 ;case set_default:case set_yes:case set_mod:
@@ -530,7 +530,7 @@ int main(int ac, char **av)break ;case 'r' : input_mode = set_random; -srandom (time (NULL )); +srand (time (NULL ));break ;case 'h' :case '?' :
@@ -538,7 +538,7 @@ int main(int ac, char **av)exit (0 ); } } - name = av[i]; + name = av[i];if (!name) {printf (_ ("%s: Kconfig file missing\n" ), av[0 ]);exit (1 );
Quoted 8 lines · Ladislav Michl
Hi,
rand and srand functions conform also to C89 in addition to POSIX.1-2001, which makes them a bit more portable (work also on MinGW host). Linux man page also says:
"The versions ofrand()andsrand()in the Linux C Library use the same random number generator asrandom()andsrandom()".
Once there, sort includes and remove leading whitespace.
I have applied the relevant bis in two patches.
One as pure cleanup and a second replacing the two remaining random functions with rand.
Sam