From: Lucas De Marchi Date: Wed, 7 Dec 2011 04:26:31 +0000 (-0200) Subject: Use streq() when possible X-Git-Tag: v1~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=877e80cd934951c02b437fd81c5a2609c20176be;p=thirdparty%2Fkmod.git Use streq() when possible --- diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c index 2859dd47..5b85fb2f 100644 --- a/libkmod/libkmod-config.c +++ b/libkmod/libkmod-config.c @@ -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); diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 25ca5d9d..e7a71503 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -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);