]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
tools: prefer the use of streq()
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 14 Jan 2015 16:22:23 +0000 (14:22 -0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 14 Jan 2015 16:32:09 +0000 (14:32 -0200)
tools/insmod.c
tools/modinfo.c

index e0c2313924eea711c811086a65d13d6f20094e93..2a0accbabf7d42d17d039f636850fc91fed68fce 100644 (file)
@@ -23,6 +23,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <shared/util.h>
+
 #include <libkmod/libkmod.h>
 
 #include "kmod.h"
@@ -102,7 +104,7 @@ static int do_insmod(int argc, char *argv[])
        }
 
        filename = argv[optind];
-       if (strcmp(filename, "-") == 0) {
+       if (streq(filename, "-")) {
                ERR("this tool does not support loading from stdin!\n");
                return EXIT_FAILURE;
        }
index 36d8795d6bc7bee3572e1f3ecbaad450ff69b0d1..94d55c92ba94a8a02b92e821e9ed144f4ecc0558 100644 (file)
@@ -97,7 +97,7 @@ static int process_parm(const char *key, const char *value, struct param **param
 
        name = value;
        namelen = colon - value;
-       if (strcmp(key, "parm") == 0) {
+       if (streq(key, "parm")) {
                param = colon + 1;
                paramlen = strlen(param);
                type = NULL;
@@ -127,8 +127,7 @@ static int modinfo_params_do(const struct kmod_list *list)
        kmod_list_foreach(l, list) {
                const char *key = kmod_module_info_get_key(l);
                const char *value = kmod_module_info_get_value(l);
-               if (strcmp(key, "parm") != 0 &&
-                   strcmp(key, "parmtype") != 0)
+               if (!streq(key, "parm") && !streq(key, "parmtype"))
                        continue;
 
                err = process_parm(key, value, &params);
@@ -175,7 +174,7 @@ static int modinfo_do(struct kmod_module *mod)
        struct param *params = NULL;
        int err;
 
-       if (field != NULL && strcmp(field, "filename") == 0) {
+       if (field != NULL && streq(field, "filename")) {
                printf("%s%c", kmod_module_get_path(mod), separator);
                return 0;
        } else if (field == NULL) {
@@ -190,7 +189,7 @@ static int modinfo_do(struct kmod_module *mod)
                return err;
        }
 
-       if (field != NULL && strcmp(field, "parm") == 0) {
+       if (field != NULL && streq(field, "parm")) {
                err = modinfo_params_do(list);
                goto end;
        }
@@ -201,14 +200,14 @@ static int modinfo_do(struct kmod_module *mod)
                int keylen;
 
                if (field != NULL) {
-                       if (strcmp(field, key) != 0)
+                       if (!streq(field, key))
                                continue;
                        /* filtered output contains no key, just value */
                        printf("%s%c", value, separator);
                        continue;
                }
 
-               if (strcmp(key, "parm") == 0 || strcmp(key, "parmtype") == 0) {
+               if (streq(key, "parm") || streq(key, "parmtype")) {
                        err = process_parm(key, value, &params);
                        if (err < 0)
                                goto end;