Style(9): the return type of strcmp() is not a boolean, so don't
authorChris Pressey <cpressey@dragonflybsd.org>
Sat, 1 Jan 2005 01:36:02 +0000 (01:36 +0000)
committerChris Pressey <cpressey@dragonflybsd.org>
Sat, 1 Jan 2005 01:36:02 +0000 (01:36 +0000)
treat it as one, explcitly compare it against zero instead.

usr.sbin/config/mkheaders.c
usr.sbin/config/mkmakefile.c
usr.sbin/config/mkoptions.c

index ac045d3..556ee19 100644 (file)
@@ -32,7 +32,7 @@
  *
  * @(#)mkheaders.c     8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.sbin/config/mkheaders.c,v 1.14.2.2 2001/01/23 00:09:32 peter Exp $
- * $DragonFly: src/usr.sbin/config/mkheaders.c,v 1.11 2004/03/08 03:28:01 dillon Exp $
+ * $DragonFly: src/usr.sbin/config/mkheaders.c,v 1.12 2005/01/01 01:36:02 cpressey Exp $
  */
 
 /*
@@ -96,7 +96,7 @@ do_count(char *dev, char *hname, int search)
         * must use the higher of these values.
         */
        for (dp = dtab; dp != NULL; dp = dp->d_next) {
-               if (!strcmp(dp->d_name, dev)) {
+               if (strcmp(dp->d_name, dev) == 0) {
                        if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE)
                                dp->d_type |= DEVDONE;
                        else if ((dp->d_type & TYPEMASK) == DEVICE)
@@ -104,7 +104,7 @@ do_count(char *dev, char *hname, int search)
                }
        }
        for (hicount = count = 0, dp = dtab; dp != NULL; dp = dp->d_next) {
-               if (dp->d_unit != -1 && !strcmp(dp->d_name, dev)) {
+               if (dp->d_unit != -1 && strcmp(dp->d_name, dev) == 0) {
                        if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE) {
                                count =
                                    dp->d_count != UNKNOWN ? dp->d_count : 1;
@@ -122,7 +122,7 @@ do_count(char *dev, char *hname, int search)
                                mp = dp->d_conn;
                                if (mp != NULL && dp->d_connunit < 0)
                                        mp = NULL;
-                               if (mp != NULL && !strcmp(mp, "nexus"))
+                               if (mp != NULL && strcmp(mp, "nexus") == 0)
                                        mp = NULL;
                                if (mp != NULL) {
                                        do_count(mp, hname, 0);
@@ -166,7 +166,7 @@ do_header(char *dev, char *hname, int count)
                if (cp == NULL || cp == (char *)EOF)
                        break;
                inc = atoi(cp);
-               if (!strcmp(inw, name)) {
+               if (strcmp(inw, name) == 0) {
                        oldcount = inc;
                        inc = count;
                }
index 86084f9..04ffb76 100644 (file)
@@ -32,7 +32,7 @@
  *
  * @(#)mkmakefile.c    8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.sbin/config/mkmakefile.c,v 1.51.2.3 2001/01/23 00:09:32 peter Exp $
- * $DragonFly: src/usr.sbin/config/mkmakefile.c,v 1.12 2004/08/30 19:27:21 eirikn Exp $
+ * $DragonFly: src/usr.sbin/config/mkmakefile.c,v 1.13 2005/01/01 01:36:02 cpressey Exp $
  */
 
 /*
@@ -93,7 +93,7 @@ fl_lookup(char *file)
        struct file_list *fp;
 
        for (fp = ftab; fp != NULL; fp = fp->f_next) {
-               if (!strcmp(fp->f_fn, file))
+               if (strcmp(fp->f_fn, file) == 0)
                        return(fp);
        }
        return(0);
@@ -108,7 +108,7 @@ fltail_lookup(char *file)
        struct file_list *fp;
 
        for (fp = ftab; fp != NULL; fp = fp->f_next) {
-               if (!strcmp(tail(fp->f_fn), tail(file)))
+               if (strcmp(tail(fp->f_fn), tail(file)) == 0)
                        return(fp);
        }
        return(0);
@@ -180,19 +180,19 @@ makefile(void)
                        fprintf(ofp, "%s", line);
                        continue;
                }
-               if (!strcmp(line, "%BEFORE_DEPEND\n"))
+               if (strcmp(line, "%BEFORE_DEPEND\n") == 0)
                        do_before_depend(ofp);
-               else if (!strcmp(line, "%OBJS\n"))
+               else if (strcmp(line, "%OBJS\n") == 0)
                        do_objs(ofp);
-               else if (!strcmp(line, "%MFILES\n"))
+               else if (strcmp(line, "%MFILES\n") == 0)
                        do_mfiles(ofp);
-               else if (!strcmp(line, "%CFILES\n"))
+               else if (strcmp(line, "%CFILES\n") == 0)
                        do_cfiles(ofp);
-               else if (!strcmp(line, "%SFILES\n"))
+               else if (strcmp(line, "%SFILES\n") == 0)
                        do_sfiles(ofp);
-               else if (!strcmp(line, "%RULES\n"))
+               else if (strcmp(line, "%RULES\n") == 0)
                        do_rules(ofp);
-               else if (!strcmp(line, "%CLEAN\n"))
+               else if (strcmp(line, "%CLEAN\n") == 0)
                        do_clean(ofp);
                else if (strncmp(line, "%VERSREQ=", sizeof("%VERSREQ=") - 1) == 0) {
                        versreq = atoi(line + sizeof("%VERSREQ=") - 1);
@@ -320,16 +320,16 @@ next:
        no_obj = 0;
        before_depend = 0;
        filetype = NORMAL;
-       if (!strcmp(wd, "standard"))
+       if (strcmp(wd, "standard") == 0)
                std = 1;
        /*
         * If an entry is marked "mandatory", config will abort if it's
         * not called by a configuration line in the config file.  Apart
         * from this, the device is handled like one marked "optional".
         */
-       else if (!strcmp(wd, "mandatory"))
+       else if (strcmp(wd, "mandatory") == 0)
                mandatory = 1;
-       else if (strcmp(wd, "optional")) {
+       else if (strcmp(wd, "optional") != 0) {
                printf("%s: %s must be optional, mandatory or standard\n",
                       fname, this);
                printf("Your version of config(8) is out of sync with your kernel source.\n");
@@ -339,15 +339,15 @@ nextparam:
        next_word(fp, wd);
        if (wd == NULL)
                goto doneparam;
-       if (!strcmp(wd, "config-dependent")) {
+       if (strcmp(wd, "config-dependent") == 0) {
                configdep++;
                goto nextparam;
        }
-       if (!strcmp(wd, "no-obj")) {
+       if (strcmp(wd, "no-obj") == 0) {
                no_obj++;
                goto nextparam;
        }
-       if (!strcmp(wd, "no-implicit-rule")) {
+       if (strcmp(wd, "no-implicit-rule") == 0) {
                if (special == NULL) {
                        printf("%s: alternate rule required when "
                               "\"no-implicit-rule\" is specified.\n",
@@ -356,11 +356,11 @@ nextparam:
                imp_rule++;
                goto nextparam;
        }
-       if (!strcmp(wd, "before-depend")) {
+       if (strcmp(wd, "before-depend") == 0) {
                before_depend++;
                goto nextparam;
        }
-       if (!strcmp(wd, "dependency")) {
+       if (strcmp(wd, "dependency") == 0) {
                next_quoted_word(fp, wd);
                if (wd == NULL) {
                        printf("%s: %s missing compile command string.\n",
@@ -370,7 +370,7 @@ nextparam:
                depends = strdup(wd);
                goto nextparam;
        }
-       if (!strcmp(wd, "clean")) {
+       if (strcmp(wd, "clean") == 0) {
                next_quoted_word(fp, wd);
                if (wd == NULL) {
                        printf("%s: %s missing clean file list.\n",
@@ -380,7 +380,7 @@ nextparam:
                clean = strdup(wd);
                goto nextparam;
        }
-       if (!strcmp(wd, "compile-with")) {
+       if (strcmp(wd, "compile-with") == 0) {
                next_quoted_word(fp, wd);
                if (wd == NULL) {
                        printf("%s: %s missing compile command string.\n",
@@ -390,7 +390,7 @@ nextparam:
                special = strdup(wd);
                goto nextparam;
        }
-       if (!strcmp(wd, "warning")) {
+       if (strcmp(wd, "warning") == 0) {
                next_quoted_word(fp, wd);
                if (wd == NULL) {
                        printf("%s: %s missing warning text string.\n",
@@ -401,19 +401,19 @@ nextparam:
                goto nextparam;
        }
        nreqs++;
-       if (!strcmp(wd, "local")) {
+       if (strcmp(wd, "local") == 0) {
                filetype = LOCAL;
                goto nextparam;
        }
-       if (!strcmp(wd, "no-depend")) {
+       if (strcmp(wd, "no-depend") == 0) {
                filetype = NODEPEND;
                goto nextparam;
        }
-       if (!strcmp(wd, "device-driver")) {
+       if (strcmp(wd, "device-driver") == 0) {
                printf("%s: `device-driver' flag obsolete.\n", fname);
                exit(1);
        }
-       if (!strcmp(wd, "profiling-routine")) {
+       if (strcmp(wd, "profiling-routine") == 0) {
                filetype = PROFILING;
                goto nextparam;
        }
@@ -422,7 +422,7 @@ nextparam:
        if (isdup)
                goto invis;
        for (dp = dtab; dp != NULL; save_dp = dp, dp = dp->d_next)
-               if (!strcmp(dp->d_name, wd)) {
+               if (strcmp(dp->d_name, wd) == 0) {
                        if (std && dp->d_type == PSEUDO_DEVICE &&
                            dp->d_count <= 0)
                                dp->d_count = 1;
index f2084e3..3a5a5c2 100644 (file)
@@ -33,7 +33,7 @@
  *
  * @(#)mkheaders.c     8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.sbin/config/mkoptions.c,v 1.17.2.3 2001/12/13 19:18:01 dillon Exp $
- * $DragonFly: src/usr.sbin/config/mkoptions.c,v 1.12 2004/03/08 03:28:02 dillon Exp $
+ * $DragonFly: src/usr.sbin/config/mkoptions.c,v 1.13 2005/01/01 01:36:02 cpressey Exp $
  */
 
 /*
@@ -124,12 +124,12 @@ do_option(char *name)
         */
        value = NULL;
        for (op = opt; op != NULL; op = op->op_next) {
-               if (!strcmp(name, op->op_name)) {
+               if (strcmp(name, op->op_name) == 0) {
                        oldvalue = value;
                        value = op->op_value;
                        if (value == NULL)
                                value = strdup("1");
-                       if (oldvalue != NULL && strcmp(value, oldvalue))
+                       if (oldvalue != NULL && strcmp(value, oldvalue) != 0)
                                printf(
                            "%s:%d: option \"%s\" redefined from %s to %s\n",
                                   PREFIX, op->op_line, op->op_name, oldvalue,
@@ -154,7 +154,7 @@ do_option(char *name)
        }
        basefile = "";
        for (ol = otab; ol != NULL; ol = ol->o_next)
-               if (!strcmp(name, ol->o_name)) {
+               if (strcmp(name, ol->o_name) == 0) {
                        basefile = ol->o_file;
                        break;
                }
@@ -178,19 +178,19 @@ do_option(char *name)
                        break;
                /* option value */
                invalue = strdup(cp); /* malloced */
-               if (!strcmp(inw, name)) {
+               if (strcmp(inw, name) == 0) {
                        oldvalue = invalue;
                        invalue = value;
                        seen++;
                }
                for (ol = otab; ol != NULL; ol = ol->o_next)
-                       if (!strcmp(inw, ol->o_name))
+                       if (strcmp(inw, ol->o_name) == 0)
                                break;
-               if (strcmp(inw, name) && ol == NULL) {
+               if (strcmp(inw, name) != 0 && ol == NULL) {
                        printf("WARNING: unknown option `%s' removed from %s\n",
                                inw, file);
                        tidy++;
-               } else if (ol != NULL && strcmp(basefile, ol->o_file)) {
+               } else if (ol != NULL && strcmp(basefile, ol->o_file) != 0) {
                        printf("WARNING: option `%s' moved from %s to %s\n",
                                inw, basefile, ol->o_file);
                        tidy++;
@@ -210,7 +210,7 @@ do_option(char *name)
        }
        fclose(inf);
        if (!tidy && ((value == NULL && oldvalue == NULL) ||
-           (value && oldvalue && !strcmp(value, oldvalue)))) { 
+           (value && oldvalue && strcmp(value, oldvalue) == 0))) {     
                for (op = op_head; op != NULL; op = topp) {
                        topp = op->op_next;
                        free(op->op_name);
@@ -261,7 +261,7 @@ tooption(char *name)
        strlcpy(nbuf, "options.h", sizeof(nbuf));
 
        for (po = otab ; po != NULL; po = po->o_next) {
-               if (!strcmp(po->o_name, name)) {
+               if (strcmp(po->o_name, name) == 0) {
                        strlcpy(nbuf, po->o_file, sizeof(nbuf));
                        break;
                }
@@ -340,7 +340,7 @@ next:
        val = strdup(val);
 
        for (po = otab; po != NULL; po = po->o_next) {
-               if (!strcmp(po->o_name, this)) {
+               if (strcmp(po->o_name, this) == 0) {
                        printf("%s: Duplicate option %s.\n",
                               fname, this);
                        exit(1);