[Olsr-dev] [PATCH v1 06/43] main: move some initialisation to the beginning of main
Ferry Huberts
(spam-protected)
Wed Nov 11 17:21:39 CET 2015
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
src/main.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/src/main.c b/src/main.c
index 17124ef..5deff57 100644
--- a/src/main.c
+++ b/src/main.c
@@ -300,6 +300,24 @@ int main(int argc, char *argv[]) {
memset(&buf, 0, sizeof(buf));
+ /* setup debug printf destination */
+ debug_handle = stdout;
+
+ /* set stdout and stderr to unbuffered output */
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
+
+ /* setup random seed */
+ olsr_init_random();
+
+ /* Init widely used statics */
+ memset(&all_zero, 0, sizeof(union olsr_ip_addr));
+
+ /* store the arguments for restart */
+#ifndef _WIN32
+ olsr_argv = argv;
+#endif /* _WIN32 */
+
/*
* Start
*/
@@ -319,15 +337,8 @@ int main(int argc, char *argv[]) {
}
}
- debug_handle = stdout;
-#ifndef _WIN32
- olsr_argv = argv;
-#endif /* _WIN32 */
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
-
+ /* check root privileges */
#ifndef _WIN32
- /* Check if user is root */
if (geteuid()) {
olsr_exit("You must be root (uid = 0) to run olsrd", EXIT_FAILURE);
}
@@ -344,12 +355,6 @@ int main(int argc, char *argv[]) {
/* Open syslog */
olsr_openlog("olsrd");
- /* setup random seed */
- olsr_init_random();
-
- /* Init widely used statics */
- memset(&all_zero, 0, sizeof(union olsr_ip_addr));
-
/*
* Set configfile name and
* check if a configfile name was given as parameter
--
2.5.0
More information about the Olsr-dev
mailing list