The init_random_seed() function is only used by the init_static() in
init.c. As this function was pretty basic and it is only being called
once, it was merged into init_static() instead of keeping it as a separate
function.
(I agree that calling functions often makes the code more readable, but
I would rather see that as a part of cleaning up the whole init_static()
function - in fact when moving all "unit tests" in init_static() to cmocka,
it will not be too bad in the end.)
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <
20170725150723.14919-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15136.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit
e74e3a4db891b3ace0a96461c597d86e87be06f0)
#endif /* if PORT_SHARE */
+
bool
init_static(void)
{
crypto_init_dmalloc();
#endif
- init_random_seed(); /* init random() function, only used as
- * source for weak random numbers */
+
+ /*
+ * Initialize random number seed. random() is only used
+ * when "weak" random numbers are acceptable.
+ * SSL library routines are always used when cryptographically
+ * strong random numbers are required.
+ */
+ struct timeval tv;
+ if (!gettimeofday(&tv, NULL))
+ {
+ const unsigned int seed = (unsigned int) tv.tv_sec ^ tv.tv_usec;
+ srandom(seed);
+ }
+
error_reset(); /* initialize error.c */
reset_check_status(); /* initialize status check code in socket.c */
-/*
- * Initialize random number seed. random() is only used
- * when "weak" random numbers are acceptable.
- * OpenSSL routines are always used when cryptographically
- * strong random numbers are required.
- */
-
-void
-init_random_seed(void)
-{
- struct timeval tv;
-
- if (!gettimeofday(&tv, NULL))
- {
- const unsigned int seed = (unsigned int) tv.tv_sec ^ tv.tv_usec;
- srandom(seed);
- }
-}
-
/*
* Set environmental variable (int or string).
*
extern int inetd_socket_descriptor;
void save_inetd_socket_descriptor(void);
-/* init random() function, only used as source for weak random numbers, when !ENABLE_CRYPTO */
-void init_random_seed(void);
-
/* set/delete environmental variable */
void setenv_str_ex(struct env_set *es,
const char *name,