Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 25 Mar 2019 09:56:13 +0000 (10:56 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 25 Mar 2019 09:56:13 +0000 (10:56 +0100)
"!strcmp" is hard to read, and "not strcmp" is misleading.

src/xbt/log.cpp

index 18da689..b109018 100644 (file)
@@ -90,17 +90,17 @@ void xbt_log_init(int *argc, char **argv)
 
   /* Set logs and init log submodule */
   for (int i = 1; i < *argc; i++) {
 
   /* Set logs and init log submodule */
   for (int i = 1; i < *argc; i++) {
-    if (!strcmp("--", argv[i])) {
+    if (strcmp("--", argv[i]) == 0) {
       parse_args = 0;
       argv[j++]  = argv[i]; // Keep the '--' for sg_config
       parse_args = 0;
       argv[j++]  = argv[i]; // Keep the '--' for sg_config
-    } else if (parse_args && !strncmp(argv[i], "--log=", strlen("--log="))) {
+    } else if (parse_args && strncmp(argv[i], "--log=", strlen("--log=")) == 0) {
       char* opt = strchr(argv[i], '=');
       opt++;
       xbt_log_control_set(opt);
       XBT_DEBUG("Did apply '%s' as log setting", opt);
       char* opt = strchr(argv[i], '=');
       opt++;
       xbt_log_control_set(opt);
       XBT_DEBUG("Did apply '%s' as log setting", opt);
-    } else if (parse_args && !strcmp(argv[i], "--help-logs")) {
+    } else if (parse_args && strcmp(argv[i], "--help-logs") == 0) {
       help_requested |= 1U;
       help_requested |= 1U;
-    } else if (parse_args && !strcmp(argv[i], "--help-log-categories")) {
+    } else if (parse_args && strcmp(argv[i], "--help-log-categories") == 0) {
       help_requested |= 2U;
     } else {
       argv[j++] = argv[i];
       help_requested |= 2U;
     } else {
       argv[j++] = argv[i];
@@ -464,7 +464,7 @@ static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, const c
   XBT_DEBUG("Search '%s' into '%s' (firstChild='%s'; nextSibling='%s')", name,
          cat->name, (cat->firstChild ? cat->firstChild->name : "none"),
          (cat->nextSibling ? cat->nextSibling->name : "none"));
   XBT_DEBUG("Search '%s' into '%s' (firstChild='%s'; nextSibling='%s')", name,
          cat->name, (cat->firstChild ? cat->firstChild->name : "none"),
          (cat->nextSibling ? cat->nextSibling->name : "none"));
-  if (!strcmp(cat->name, name))
+  if (strcmp(cat->name, name) == 0)
     return cat;
 
   for (child = cat->firstChild; child != nullptr; child = child->nextSibling) {
     return cat;
 
   for (child = cat->firstChild; child != nullptr; child = child->nextSibling) {
@@ -508,7 +508,7 @@ void xbt_log_control_set(const char *control_string)
   XBT_DEBUG("Parse log settings '%s'", control_string);
 
   /* Special handling of no_loc request, which asks for any file localization to be omitted (for tesh runs) */
   XBT_DEBUG("Parse log settings '%s'", control_string);
 
   /* Special handling of no_loc request, which asks for any file localization to be omitted (for tesh runs) */
-  if (!strcmp(control_string, "no_loc")) {
+  if (strcmp(control_string, "no_loc") == 0) {
     xbt_log_no_loc = 1;
     return;
   }
     xbt_log_no_loc = 1;
     return;
   }