ncurses: Fix bad strncmp
authorJoel Stanley <joel@jms.id.au>
Tue, 6 Mar 2018 04:02:17 +0000 (14:32 +1030)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 7 Mar 2018 05:24:31 +0000 (16:24 +1100)
ui/ncurses/nc-cui.c:967:58: warning: size argument in 'strncmp' call is a comparison [-Wmemsize-comparison]
        if (strncmp(cod->opt->id, "dummy", strlen("dummy") == 0 &&
                                           ~~~~~~~~~~~~~~~~~~~~~^~
ui/ncurses/nc-cui.c:967:6: note: did you mean to compare the result of 'strncmp' instead?
        if (strncmp(cod->opt->id, "dummy", strlen("dummy") == 0 &&
            ^

There appears to be two bonus conditions inside the length field. I
chose to drop the  pointless strncmp(foo, bar, strlen(bar)), as this is
equivalent to strcmp(foo, bar).

Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
[Fixed up commit message typo]

ui/ncurses/nc-cui.c

index 372da1e7a13e154a3ba460e31a2691b8932fc746..20a90483cd07accc318546d9fc26aab48c9f72dc 100644 (file)
@@ -964,8 +964,8 @@ fallback:
         * If this option was faked above move the context under
         * the item so it is cleaned up later in cui_plugins_remove().
         */
-       if (strncmp(cod->opt->id, "dummy", strlen("dummy") == 0 &&
-                               cod->dev->type == DEVICE_TYPE_UNKNOWN)) {
+       if (strcmp(cod->opt->id, "dummy") == 0 &&
+                       cod->dev->type == DEVICE_TYPE_UNKNOWN) {
                talloc_steal(item, cod->dev);
                talloc_steal(item, cod->opt);
        }