Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make some C functions as such to please sonar
[simgrid.git] / src / xbt / log.c
index 67c19a8..2d694db 100644 (file)
@@ -277,7 +277,8 @@ static void xbt_log_help_categories(void);
 void xbt_log_init(int *argc, char **argv)
 {
   unsigned help_requested = 0;  /* 1: logs; 2: categories */
-  int i, j;
+  int i;
+  int j;
   char *opt;
 
   /* uncomment to set the LOG category to debug directly */
@@ -366,11 +367,10 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
     /* First, try with a static buffer */
     if (XBT_LOG_STATIC_BUFFER_SIZE) {
       char buff[XBT_LOG_STATIC_BUFFER_SIZE];
-      int done;
       ev->buffer = buff;
       ev->buffer_size = sizeof buff;
       va_start(ev->ap, fmt);
-      done = cat->layout->do_layout(cat->layout, ev, fmt);
+      int done = cat->layout->do_layout(cat->layout, ev, fmt);
       va_end(ev->ap);
       if (done) {
         appender->do_append(appender, buff);
@@ -382,9 +382,8 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
     ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
     ev->buffer = xbt_malloc(ev->buffer_size);
     while (1) {
-      int done;
       va_start(ev->ap, fmt);
-      done = cat->layout->do_layout(cat->layout, ev, fmt);
+      int done = cat->layout->do_layout(cat->layout, ev, fmt);
       va_end(ev->ap);
       if (done)
         break;                  /* Got it */
@@ -588,7 +587,6 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string)
 {
   const char *orig_control_string = control_string;
   xbt_log_setting_t set = xbt_new(s_xbt_log_setting_t, 1);
-  const char *name, *dot, *eq;
 
   set->catname = NULL;
   set->thresh = xbt_log_priority_uninitialized;
@@ -601,11 +599,11 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string)
   XBT_DEBUG("Parse log setting '%s'", control_string);
 
   control_string += strspn(control_string, " ");
-  name = control_string;
+  const char *name = control_string;
   control_string += strcspn(control_string, ".= ");
-  dot = control_string;
+  const char *dot = control_string;
   control_string += strcspn(control_string, ":= ");
-  eq = control_string;
+  const char *eq = control_string;
 
   if(*dot != '.' && (*eq == '=' || *eq == ':'))
     xbt_die ("Invalid control string '%s'", orig_control_string);
@@ -666,9 +664,9 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string)
     if (!strncmp(neweq, "file:", 5)) {
       set->appender = xbt_log_appender_file_new(neweq + 5);
     }else if (!strncmp(neweq, "rollfile:", 9)) {
-    set->appender = xbt_log_appender2_file_new(neweq + 9,1);
+      set->appender = xbt_log_appender2_file_new(neweq + 9,1);
     }else if (!strncmp(neweq, "splitfile:", 10)) {
-    set->appender = xbt_log_appender2_file_new(neweq + 10,0);
+      set->appender = xbt_log_appender2_file_new(neweq + 10,0);
     } else {
       THROWF(arg_error, 0, "Unknown appender log type: '%s'", neweq);
     }
@@ -691,7 +689,8 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string)
 
 static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, char *name)
 {
-  xbt_log_category_t child, res;
+  xbt_log_category_t child;
+  xbt_log_category_t res;
 
   XBT_DEBUG("Search '%s' into '%s' (firstChild='%s'; nextSibling='%s')", name,
          cat->name, (cat->firstChild ? cat->firstChild->name : "none"),
@@ -874,7 +873,6 @@ static void xbt_log_help_categories_rec(xbt_log_category_t category, const char
 {
   char *this_prefix;
   char *child_prefix;
-  xbt_dynar_t dynar;
   unsigned i;
   xbt_log_category_t cat;
 
@@ -889,7 +887,7 @@ static void xbt_log_help_categories_rec(xbt_log_category_t category, const char
     child_prefix = xbt_strdup(prefix);
   }
 
-  dynar = xbt_dynar_new(sizeof(xbt_log_category_t), NULL);
+  xbt_dynar_t dynar = xbt_dynar_new(sizeof(xbt_log_category_t), NULL);
   for (cat = category ; cat != NULL; cat = cat->nextSibling)
     xbt_dynar_push_as(dynar, xbt_log_category_t, cat);