]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Use streq() when possible
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 7 Dec 2011 04:26:31 +0000 (02:26 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 7 Dec 2011 04:32:28 +0000 (02:32 -0200)
libkmod/libkmod-config.c
libkmod/libkmod-module.c

index 2859dd47265ad3194d70363900f463f49710a757..5b85fb2f84c7917c478edd43fc59d338e63e2a60 100644 (file)
@@ -155,7 +155,7 @@ static int kmod_config_parse(struct kmod_config *config, int fd,
                if (cmd == NULL)
                        goto done_next;
 
-               if (!strcmp(cmd, "alias")) {
+               if (streq(cmd, "alias")) {
                        char *alias = strtok_r(NULL, "\t ", &saveptr);
                        char *modname = strtok_r(NULL, "\t ", &saveptr);
 
@@ -165,7 +165,7 @@ static int kmod_config_parse(struct kmod_config *config, int fd,
                        kmod_config_add_alias(config,
                                                underscores(ctx, alias),
                                                underscores(ctx, modname));
-               } else if (!strcmp(cmd, "blacklist")) {
+               } else if (streq(cmd, "blacklist")) {
                        char *modname = strtok_r(NULL, "\t ", &saveptr);
 
                        if (modname == NULL)
@@ -173,11 +173,11 @@ static int kmod_config_parse(struct kmod_config *config, int fd,
 
                        kmod_config_add_blacklist(config,
                                                underscores(ctx, modname));
-               } else if (!strcmp(cmd, "include") || !strcmp(cmd, "options")
-                               || !strcmp(cmd, "install")
-                               || !strcmp(cmd, "remove")
-                               || !strcmp(cmd, "softdep")
-                               || !strcmp(cmd, "config")) {
+               } else if (streq(cmd, "include") || streq(cmd, "options")
+                               || streq(cmd, "install")
+                               || streq(cmd, "remove")
+                               || streq(cmd, "softdep")
+                               || streq(cmd, "config")) {
                        INFO(ctx, "%s: command %s not implemented yet\n",
                                                                filename, cmd);
                } else {
@@ -214,8 +214,8 @@ static bool conf_files_filter_out(struct kmod_ctx *ctx, const char *path,
        if (fn[0] == '.')
                return 1;
 
-       if (len < 6 || (strcmp(&fn[len - 5], ".conf") != 0
-                               && strcmp(&fn[len - 6], ".alias"))) {
+       if (len < 6 || (!streq(&fn[len - 5], ".conf")
+                               && !streq(&fn[len - 6], ".alias"))) {
                INFO(ctx, "All config files need .conf: %s/%s, "
                                "it will be ignored in a future release\n",
                                path, fn);
index 25ca5d9d0abbf5421086efbd8dd884c6b8021429..e7a71503c00dd53c8e2329a7bc9f0f14d86a3b8a 100644 (file)
@@ -372,7 +372,7 @@ KMOD_EXPORT long kmod_module_get_size(const struct kmod_module *mod)
                long value;
 
                lineno++;
-               if (tok == NULL || strcmp(tok, mod->name) != 0)
+               if (tok == NULL || !streq(tok, mod->name))
                        continue;
 
                tok = strtok_r(NULL, " \t", &saveptr);
@@ -540,11 +540,11 @@ KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod)
                return err;
        }
 
-       if (strcmp(buf, "live\n") == 0)
+       if (streq(buf, "live\n"))
                return KMOD_MODULE_LIVE;
-       else if (strcmp(buf, "coming\n") == 0)
+       else if (streq(buf, "coming\n"))
                return KMOD_MODULE_COMING;
-       else if (strcmp(buf, "going\n") == 0)
+       else if (streq(buf, "going\n"))
                return KMOD_MODULE_GOING;
 
        ERR(mod->ctx, "unknown %s: '%s'\n", path, buf);