[Olsr-dev] [PATCH v1 26/43] main: move conf_file_name variable into cfgparser

Ferry Huberts (spam-protected)
Wed Nov 11 17:21:59 CET 2015


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 src/cfgparser/olsrd_conf.c | 7 ++++---
 src/cfgparser/olsrd_conf.h | 2 +-
 src/main.c                 | 3 +--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/cfgparser/olsrd_conf.c b/src/cfgparser/olsrd_conf.c
index 3cf31c4..32104dd 100644
--- a/src/cfgparser/olsrd_conf.c
+++ b/src/cfgparser/olsrd_conf.c
@@ -165,7 +165,8 @@ olsrmain_load_config(char *file) {
  * Set configfile name and
  * check if a configfile name was given as parameter
  */
-bool loadConfig(int *argc, char *argv[], char * conf_file_name, int conf_file_name_size) {
+bool loadConfig(int *argc, char *argv[]) {
+  char conf_file_name[FILENAME_MAX] = { 0 };
   bool loadedConfig = false;
   int i;
 
@@ -187,7 +188,7 @@ bool loadConfig(int *argc, char *argv[], char * conf_file_name, int conf_file_na
 
   strscpy(conf_file_name + len, "olsrd.conf", sizeof(conf_file_name) - len);
 #else /* _WIN32 */
-  strscpy(conf_file_name, OLSRD_GLOBAL_CONF_FILE, conf_file_name_size);
+  strscpy(conf_file_name, OLSRD_GLOBAL_CONF_FILE, sizeof(conf_file_name));
 #endif /* _WIN32 */
 
   /* get the default configuration */
@@ -197,7 +198,7 @@ bool loadConfig(int *argc, char *argv[], char * conf_file_name, int conf_file_na
   for (i = 1; i < (*argc - 1);) {
     if (strcmp(argv[i], "-f") == 0) {
       /* setup the provided olsrd configuration file name in conf_file_name */
-      strscpy(conf_file_name, argv[i + 1], conf_file_name_size);
+      strscpy(conf_file_name, argv[i + 1], sizeof(conf_file_name));
 
       /* remove -f confgFile arguments from argc and argv */
       if ((i + 2) < *argc) {
diff --git a/src/cfgparser/olsrd_conf.h b/src/cfgparser/olsrd_conf.h
index ba9af54..257f8ea 100644
--- a/src/cfgparser/olsrd_conf.h
+++ b/src/cfgparser/olsrd_conf.h
@@ -59,7 +59,7 @@ struct conf_token {
 #define DEFAULT_STR(val) \
 (((!defcnf) && ((*((uint8_t *)(&cnfi->val)))==0))?" (d)":"")
 
-bool loadConfig(int *argc, char *argv[], char * conf_file_name, int conf_file_name_size);
+bool loadConfig(int *argc, char *argv[]);
 
 void set_default_cnf(struct olsrd_config *, char * configuration_file);
 
diff --git a/src/main.c b/src/main.c
index c16179e..fbcdcd0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -112,7 +112,6 @@ struct olsr_cookie_info *def_timer_ci = NULL;
 
 int main(int argc, char *argv[]) {
   int argcLocal = argc;
-  char conf_file_name[FILENAME_MAX] = { 0 };
   struct ipaddr_str buf;
 
 #ifdef __linux__
@@ -182,7 +181,7 @@ int main(int argc, char *argv[]) {
   olsr_openlog("olsrd");
 
   /* load the configuration */
-  if (!loadConfig(&argcLocal, argv, conf_file_name, sizeof(conf_file_name))) {
+  if (!loadConfig(&argcLocal, argv)) {
     olsr_exit(NULL, EXIT_FAILURE);
   }
 
-- 
2.5.0




More information about the Olsr-dev mailing list