]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: Apply the coccinelle patch for `XXXcmp()` on contrib/
authorTim Duesterhus <tim@bastelstu.be>
Sat, 2 Jan 2021 21:31:55 +0000 (22:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 4 Jan 2021 09:09:02 +0000 (10:09 +0100)
Compare the various `cmp()` functions against zero.

contrib/mod_defender/spoa.c
contrib/mod_defender/standalone.c
contrib/modsecurity/spoa.c
contrib/prometheus-exporter/service-prometheus.c
contrib/spoa_example/spoa.c

index 2ae1a366cf68cfe3d93bcf2a85587dc883dfa495..78c009e2ebb14bbb75bd71a41765c8966a5f35a8 100644 (file)
@@ -1044,7 +1044,7 @@ use_spoe_engine(struct client *client)
                return;
 
        list_for_each_entry(eng, &client->worker->engines, list) {
-               if (!strcmp(eng->id, client->engine_id))
+               if (strcmp(eng->id, client->engine_id) == 0)
                        goto end;
        }
 
@@ -1749,11 +1749,11 @@ main(int argc, char **argv)
                                server_port = atoi(optarg);
                                break;
                        case 'c':
-                               if (!strcmp(optarg, "pipelining"))
+                               if (strcmp(optarg, "pipelining") == 0)
                                        pipelining = true;
-                               else if (!strcmp(optarg, "async"))
+                               else if (strcmp(optarg, "async") == 0)
                                        async = true;
-                               else if (!strcmp(optarg, "fragmentation"))
+                               else if (strcmp(optarg, "fragmentation") == 0)
                                        fragmentation = true;
                                else
                                        fprintf(stderr, "WARNING: unsupported capability '%s'\n", optarg);
index f926ec174d91fcb166c0f9f3986b4feeeb52a30b..58d1940a24eee09f49b49ae42aa4280b5070a5ac 100644 (file)
@@ -863,7 +863,7 @@ static const command_rec *find_command(const char *name,
                                        const command_rec *cmds)
 {
        while (cmds->name) {
-               if (!strcasecmp(name, cmds->name))
+               if (strcasecmp(name, cmds->name) == 0)
                        return cmds;
                ++cmds;
        }
@@ -1044,7 +1044,7 @@ static const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
                 */
                w = getword_conf(parms->temp_pool, &args);
 
-               if (*w == '\0' || (strcasecmp(w, "on") && strcasecmp(w, "off")))
+               if (*w == '\0' || (strcasecmp(w, "on") != 0 && strcasecmp(w, "off") != 0))
                        return apr_pstrcat(parms->pool, cmd->name, " must be On or Off",
                                           NULL);
 
@@ -1151,8 +1151,8 @@ static const char *process_resource_config_nofnmatch(const char *fname,
                candidates = apr_array_make(ptemp, 1, sizeof(fnames));
                while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
                        /* strip out '.' and '..' */
-                       if (strcmp(dirent.name, ".")
-                           && strcmp(dirent.name, "..")) {
+                       if (strcmp(dirent.name, ".") != 0
+                           && strcmp(dirent.name, "..") != 0) {
                                fnew = (fnames *) apr_array_push(candidates);
                                fnew->fname = make_full_path(ptemp, path, dirent.name);
                        }
@@ -1236,8 +1236,8 @@ static const char *process_resource_config_fnmatch(const char *path,
        candidates = apr_array_make(ptemp, 1, sizeof(fnames));
        while (apr_dir_read(&dirent, APR_FINFO_DIRENT | APR_FINFO_TYPE, dirp) == APR_SUCCESS) {
                /* strip out '.' and '..' */
-               if (strcmp(dirent.name, ".")
-                   && strcmp(dirent.name, "..")
+               if (strcmp(dirent.name, ".") != 0
+                   && strcmp(dirent.name, "..") != 0
                    && (apr_fnmatch(fname, dirent.name,
                                        APR_FNM_PERIOD) == APR_SUCCESS)) {
                        const char *full_path = make_full_path(ptemp, path, dirent.name);
@@ -1388,12 +1388,12 @@ const char *read_module_config(server_rec *s, void *mconfig,
                                continue;
 
                        /* similar to invoke_cmd() */
-                       if (!strcasecmp(cmd_name, "IncludeOptional") ||
-                           !strcasecmp(cmd_name, "Include"))
+                       if (strcasecmp(cmd_name, "IncludeOptional") == 0 ||
+                           strcasecmp(cmd_name, "Include") == 0)
                        {
                                char *w, *fullname;
 
-                               if (!strcasecmp(cmd_name, "IncludeOptional"))
+                               if (strcasecmp(cmd_name, "IncludeOptional") == 0)
                                        optional = 1;
 
                                w = getword_conf(parms->pool, &args);
index 1a6cd90103169035577a69c8deaa1ed6ee7cdde5..b0b042ee7e31c74630169859d9df4f0bbe396ecc 100644 (file)
@@ -1049,7 +1049,7 @@ use_spoe_engine(struct client *client)
                return;
 
        list_for_each_entry(eng, &client->worker->engines, list) {
-               if (!strcmp(eng->id, client->engine_id))
+               if (strcmp(eng->id, client->engine_id) == 0)
                        goto end;
        }
 
@@ -1773,11 +1773,11 @@ main(int argc, char **argv)
                                configuration_file = optarg;
                                break;
                        case 'c':
-                               if (!strcmp(optarg, "pipelining"))
+                               if (strcmp(optarg, "pipelining") == 0)
                                        pipelining = true;
-                               else if (!strcmp(optarg, "async"))
+                               else if (strcmp(optarg, "async") == 0)
                                        async = true;
-                               else if (!strcmp(optarg, "fragmentation"))
+                               else if (strcmp(optarg, "fragmentation") == 0)
                                        fragmentation = true;
                                else
                                        fprintf(stderr, "WARNING: unsupported capability '%s'\n", optarg);
index b6c38eb579fae5c7aaeec84a747e9d4a4c3035de..c2feccc76a9d258d67ed8fe2fb626fd891dc0e95 100644 (file)
@@ -2394,7 +2394,7 @@ static int promex_parse_uri(struct appctx *appctx, struct stream_interface *si)
                                goto error;
                }
 
-               if (!strcmp(key, "scope")) {
+               if (strcmp(key, "scope") == 0) {
                        default_scopes = 0; /* at least a scope defined, unset default scopes */
                        if (!value)
                                goto error;
@@ -2402,18 +2402,18 @@ static int promex_parse_uri(struct appctx *appctx, struct stream_interface *si)
                                appctx->ctx.stats.flags &= ~PROMEX_FL_SCOPE_ALL;
                        else if (*value == '*')
                                appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_ALL;
-                       else if (!strcmp(value, "global"))
+                       else if (strcmp(value, "global") == 0)
                                appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_GLOBAL;
-                       else if (!strcmp(value, "server"))
+                       else if (strcmp(value, "server") == 0)
                                appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_SERVER;
-                       else if (!strcmp(value, "backend"))
+                       else if (strcmp(value, "backend") == 0)
                                appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_BACK;
-                       else if (!strcmp(value, "frontend"))
+                       else if (strcmp(value, "frontend") == 0)
                                appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_FRONT;
                        else
                                goto error;
                }
-               else if (!strcmp(key, "no-maint"))
+               else if (strcmp(key, "no-maint") == 0)
                        appctx->ctx.stats.flags |= PROMEX_FL_NO_MAINT_SRV;
        }
 
index 9725078154bdea161a09f27f297dcfa3555b6896..3f96d849ac8dcf0765ef1d66c441dd8ce48c3d5c 100644 (file)
@@ -1100,7 +1100,7 @@ use_spoe_engine(struct client *client)
                return;
 
        list_for_each_entry(eng, &client->worker->engines, list) {
-               if (!strcmp(eng->id, client->engine_id))
+               if (strcmp(eng->id, client->engine_id) == 0)
                        goto end;
        }
 
@@ -1762,11 +1762,11 @@ main(int argc, char **argv)
                                server_port = atoi(optarg);
                                break;
                        case 'c':
-                               if (!strcmp(optarg, "pipelining"))
+                               if (strcmp(optarg, "pipelining") == 0)
                                        pipelining = true;
-                               else if (!strcmp(optarg, "async"))
+                               else if (strcmp(optarg, "async") == 0)
                                        async = true;
-                               else if (!strcmp(optarg, "fragmentation"))
+                               else if (strcmp(optarg, "fragmentation") == 0)
                                        fragmentation = true;
                                else
                                        fprintf(stderr, "WARNING: unsupported capability '%s'\n", optarg);