Ver código fonte

Use cmp() == 0 instead of !cmp()

Guillem Jover 14 anos atrás
pai
commit
6431c053b7

+ 3 - 3
dpkg-deb/extract.c

@@ -130,7 +130,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
   if (r < 0)
     read_fail(r, debar, _("archive magic version number"));
 
-  if (!strcmp(versionbuf, DPKG_AR_MAGIC)) {
+  if (strcmp(versionbuf, DPKG_AR_MAGIC) == 0) {
     oldformat = false;
 
     ctrllennum= 0;
@@ -216,7 +216,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
              versionbuf, (intmax_t)stab.st_size, (intmax_t)ctrllennum);
       m_output(stdout, _("<standard output>"));
     }
-  } else if (!strncmp(versionbuf,"0.93",4) &&
+  } else if (strncmp(versionbuf, "0.93", 4) == 0 &&
              sscanf(versionbuf,"%f%c%d",&versionnum,&nlc,&dummy) == 2 &&
              nlc == '\n') {
     char ctrllenbuf[40];
@@ -250,7 +250,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
       m_output(stdout, _("<standard output>"));
     }
   } else {
-    if (!strncmp(versionbuf,"!<arch>",7)) {
+    if (strncmp(versionbuf, "!<arch>", 7) == 0) {
       fprintf(stderr,
               _("dpkg-deb: file looks like it might be an archive which has been\n"
                 "dpkg-deb:    corrupted by being downloaded in ASCII mode\n"));

+ 1 - 1
dpkg-deb/info.c

@@ -240,7 +240,7 @@ info_field(const char *debar, const char *dir, const char *const *fields,
       *pf = '\0';
       doing= fnl >= MAXFIELDNAME || c=='\n' || c==EOF;
       for (fp=fields; !doing && *fp; fp++)
-        if (!strcasecmp(*fp, fieldname))
+        if (strcasecmp(*fp, fieldname) == 0)
           doing = true;
       if (showfieldname) {
         if (doing)

+ 1 - 1
dpkg-split/queue.c

@@ -115,7 +115,7 @@ static bool
 partmatches(struct partinfo *pi, struct partinfo *refi)
 {
   return (pi->md5sum &&
-          !strcmp(pi->md5sum,refi->md5sum) &&
+          strcmp(pi->md5sum, refi->md5sum) == 0 &&
           pi->maxpartn == refi->maxpartn &&
           pi->maxpartlen == refi->maxpartlen);
 }

+ 1 - 1
dpkg-split/split.c

@@ -257,7 +257,7 @@ do_split(const char *const *argv)
 		l = strlen(sourcefile);
 		palloc = nfmalloc(l + 1);
 		strcpy(palloc, sourcefile);
-		if (!strcmp(palloc + l - (sizeof(DEBEXT) - 1), DEBEXT)) {
+		if (strcmp(palloc + l - (sizeof(DEBEXT) - 1), DEBEXT) == 0) {
 			l -= (sizeof(DEBEXT) - 1);
 			palloc[l] = '\0';
 		}

+ 1 - 1
dselect/basecmds.cc

@@ -112,7 +112,7 @@ baselist::matchsearch(int index)
   searchlen=strlen(searchstring);
   lendiff = strlen(name) - searchlen;
   for (i=0; i<=lendiff; i++)
-    if (!strncasecmp(name + i, searchstring, searchlen))
+    if (strncasecmp(name + i, searchstring, searchlen) == 0)
       return true;
 
   return false;

+ 2 - 2
dselect/bindings.cc

@@ -97,7 +97,7 @@ const char **keybindings::describenext() {
   for (;;) {
     if (!iterate->action) return 0;
     for (count=0, search=bindings; search; search=search->next)
-      if (!strcmp(search->interp->action,iterate->action))
+      if (strcmp(search->interp->action, iterate->action) == 0)
         count++;
     if (count) break;
     iterate++;
@@ -105,7 +105,7 @@ const char **keybindings::describenext() {
   const char **retarray= new const char *[count+2];
   retarray[0]= iterate->desc;
   for (count=1, search=bindings; search; search=search->next)
-    if (!strcmp(search->interp->action,iterate->action))
+    if (strcmp(search->interp->action, iterate->action) == 0)
       retarray[count++]= key2name(search->key);
   retarray[count]= 0;
   iterate++;

+ 1 - 1
dselect/pkgcmds.cc

@@ -195,7 +195,7 @@ void packagelist::resortredisplay() {
     int index;
     for (index=0; index<nitems; index++) {
       if (table[index]->pkg->set->name &&
-          !strcasecmp(oldname, table[index]->pkg->set->name)) {
+          strcasecmp(oldname, table[index]->pkg->set->name) == 0) {
         newcursor= index;
         break;
       }

+ 1 - 1
lib/dpkg/fields.c

@@ -324,7 +324,7 @@ f_conffiles(struct pkginfo *pigp, struct pkgbin *pifp,
 			&hashstart, &hashlen, &endfn,
                         ps);
     obsolete= (hashlen == sizeof(obsolete_str)-1 &&
-	       !memcmp(hashstart, obsolete_str, hashlen));
+               memcmp(hashstart, obsolete_str, hashlen) == 0);
     if (obsolete)
       conffvalue_lastword(value, endfn, endent,
 			  &hashstart, &hashlen, &endfn,

+ 8 - 5
lib/dpkg/options.c

@@ -106,10 +106,11 @@ myfileopt(const char *fn, const struct cmdinfo *cmdinfos)
 
     for (cip=cmdinfos; cip->olong || cip->oshort; cip++) {
       if (!cip->olong) continue;
-      if (!strcmp(cip->olong,linebuf)) break;
+      if (strcmp(cip->olong, linebuf) == 0)
+        break;
       l=strlen(cip->olong);
       if ((cip->takesvalue==2) && (linebuf[l]=='-') &&
-	  !opt && !strncmp(linebuf,cip->olong,l)) {
+          !opt && strncmp(linebuf, cip->olong, l) == 0) {
 	opt=linebuf+l+1;
 	break;
       }
@@ -217,16 +218,18 @@ myopt(const char *const **argvp, const struct cmdinfo *cmdinfos,
   ++(*argvp);
   while ((p= **argvp) && *p == '-') {
     ++(*argvp);
-    if (!strcmp(p,"--")) break;
+    if (strcmp(p, "--") == 0)
+      break;
     if (*++p == '-') {
       ++p; value=NULL;
       for (cip= cmdinfos;
            cip->olong || cip->oshort;
            cip++) {
         if (!cip->olong) continue;
-        if (!strcmp(p,cip->olong)) break;
+        if (strcmp(p, cip->olong) == 0)
+          break;
         l= strlen(cip->olong);
-        if (!strncmp(p,cip->olong,l) &&
+        if (strncmp(p, cip->olong, l) == 0 &&
             (p[l]== ((cip->takesvalue==2) ? '-' : '='))) { value=p+l+1; break; }
       }
       if (!cip->olong) badusage(_("unknown option --%s"),p);

+ 1 - 1
lib/dpkg/parse.c

@@ -150,7 +150,7 @@ pkg_parse_field(struct parsedb_state *ps, struct field_state *fs,
                   fs->fieldlen, fs->fieldstart);
     larpp = &pkg_obj->pkgbin->arbs;
     while ((arp = *larpp) != NULL) {
-      if (!strncasecmp(arp->name, fs->fieldstart, fs->fieldlen))
+      if (strncasecmp(arp->name, fs->fieldstart, fs->fieldlen) == 0)
         parse_error(ps,
                    _("duplicate value for user-defined field `%.*s'"),
                    fs->fieldlen, fs->fieldstart);

+ 5 - 5
lib/dpkg/triglib.c

@@ -667,13 +667,13 @@ trig_parse_ci(const char *file, trig_parse_cicb *interest,
 		*spc++ = '\0';
 		while (cisspace(*spc))
 			spc++;
-		if (!strcmp(cmd, "interest")) {
+		if (strcmp(cmd, "interest") == 0) {
 			parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, trig_await);
-		} else if (!strcmp(cmd, "interest-noawait")) {
+		} else if (strcmp(cmd, "interest-noawait") == 0) {
 			parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, trig_noawait);
-		} else if (!strcmp(cmd, "activate")) {
+		} else if (strcmp(cmd, "activate") == 0) {
 			parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, trig_await);
-		} else if (!strcmp(cmd, "activate-noawait")) {
+		} else if (strcmp(cmd, "activate-noawait") == 0) {
 			parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, trig_noawait);
 		} else {
 			ohshit(_("triggers ci file contains unknown directive `%.250s'"),
@@ -789,7 +789,7 @@ th_simple_nn_find(const char *name, bool nonew)
 	struct filenamenode *search;
 
 	for (search = trigger_files; search; search = search->next)
-		if (!strcmp(search->name, name))
+		if (strcmp(search->name, name) == 0)
 			return search;
 
 	/* Not found. */

+ 1 - 1
lib/dpkg/trignote.c

@@ -41,7 +41,7 @@ trig_note_pend_core(struct pkginfo *pend, const char *trig)
 	struct trigpend *tp;
 
 	for (tp = pend->trigpend_head; tp; tp = tp->next)
-		if (!strcmp(tp->name, trig))
+		if (strcmp(tp->name, trig) == 0)
 			return false;
 
 	tp = nfmalloc(sizeof(*tp));

+ 5 - 5
src/configure.c

@@ -118,13 +118,13 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 		        cdr.buf);
 
 	/* Select what to do. */
-	if (!strcmp(currenthash, newdisthash)) {
+	if (strcmp(currenthash, newdisthash) == 0) {
 		/* They're both the same so there's no point asking silly
 		 * questions. */
 		useredited = -1;
 		distedited = -1;
 		what = cfo_identical;
-	} else if (!strcmp(currenthash, NONEXISTENTFLAG) && fc_conff_miss) {
+	} else if (strcmp(currenthash, NONEXISTENTFLAG) == 0&& fc_conff_miss) {
 		fprintf(stderr,
 		        _("\n"
 		          "Configuration file `%s', does not exist on system.\n"
@@ -133,8 +133,8 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 		what = cfo_newconff;
 		useredited = -1;
 		distedited = -1;
-	} else if (!strcmp(conff->hash, NEWCONFFILEFLAG)) {
-		if (!strcmp(currenthash, NONEXISTENTFLAG)) {
+	} else if (strcmp(conff->hash, NEWCONFFILEFLAG) == 0) {
+		if (strcmp(currenthash, NONEXISTENTFLAG) == 0) {
 			what = cfo_newconff;
 			useredited = -1;
 			distedited = -1;
@@ -153,7 +153,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 		else
 			what = conffoptcells[useredited][distedited];
 
-		if (!strcmp(currenthash, NONEXISTENTFLAG))
+		if (strcmp(currenthash, NONEXISTENTFLAG) == 0)
 			what |= cfof_userrmd;
 	}
 

+ 2 - 1
src/filesdb.c

@@ -673,7 +673,8 @@ struct filenamenode *findnamenode(const char *name, enum fnnflags flags) {
   while (*pointerp) {
     /* XXX: Why is the assert needed? It's checking already added entries. */
     assert((*pointerp)->name[0] == '/');
-    if (!strcmp((*pointerp)->name+1,name)) break;
+    if (strcmp((*pointerp)->name + 1, name) == 0)
+      break;
     pointerp= &(*pointerp)->next;
   }
   if (*pointerp) return *pointerp;

+ 3 - 2
src/main.c

@@ -557,7 +557,7 @@ static void setforce(const struct cmdinfo *cip, const char *value) {
   size_t l;
   const struct forceinfo *fip;
 
-  if (!strcmp(value,"help")) {
+  if (strcmp(value, "help") == 0) {
     printf(_(
 "%s forcing options - control behaviour when problems found:\n"
 "  warn but continue:  --force-<thing>,<thing>,...\n"
@@ -580,7 +580,8 @@ static void setforce(const struct cmdinfo *cip, const char *value) {
     comma= strchr(value,',');
     l = comma ? (size_t)(comma - value) : strlen(value);
     for (fip=forceinfos; fip->name; fip++)
-      if (!strncmp(fip->name,value,l) && strlen(fip->name)==l) break;
+      if (strncmp(fip->name, value, l) == 0 && strlen(fip->name) == l)
+        break;
 
     if (!fip->name) {
       badusage(_("unknown force/refuse option `%.*s'"),

+ 2 - 2
src/processarc.c

@@ -1065,7 +1065,7 @@ void process_archive(const char *filename) {
       if ((namenode->flags & fnnf_old_conff)) {
 	if (sameas) {
 	  if (sameas->namenode->flags & fnnf_new_conff) {
-	    if (!strcmp(sameas->namenode->oldhash, NEWCONFFILEFLAG)) {
+	    if (strcmp(sameas->namenode->oldhash, NEWCONFFILEFLAG) == 0) {
 	      sameas->namenode->oldhash= namenode->oldhash;
 	      debug(dbg_eachfile, "process_archive: old conff %s"
 		    " is same as new conff %s, copying hash",
@@ -1244,7 +1244,7 @@ void process_archive(const char *filename) {
     assert(otherpkg->clientdata->istobe == itb_normal ||
            otherpkg->clientdata->istobe == itb_deconfigure);
     for (cfile= otherpkg->clientdata->files;
-         cfile && !strcmp(cfile->namenode->name,"/.");
+         cfile && strcmp(cfile->namenode->name, "/.") == 0;
          cfile= cfile->next);
     if (!cfile) {
       debug(dbg_stupidlyverbose, "process_archive no non-root, no disappear");

+ 5 - 4
src/remove.c

@@ -538,10 +538,11 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry='%s'"
               " conffbasename='%s' conffnameused=%d conffbasenamelen=%d",
               de->d_name, conffbasename, conffnameused, conffbasenamelen);
-        if (!strncmp(de->d_name,conffbasename,conffbasenamelen)) {
+        if (strncmp(de->d_name, conffbasename, conffbasenamelen) == 0) {
           debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry starts right");
           for (ext= removeconffexts; *ext; ext++)
-            if (!strcmp(*ext,de->d_name+conffbasenamelen)) goto yes_remove;
+            if (strcmp(*ext, de->d_name + conffbasenamelen) == 0)
+              goto yes_remove;
           p= de->d_name+conffbasenamelen;
           if (*p++ == '~') {
             while (*p && cisdigit(*p)) p++;
@@ -550,8 +551,8 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
         }
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry starts wrong");
         if (de->d_name[0] == '#' &&
-            !strncmp(de->d_name+1,conffbasename,conffbasenamelen) &&
-            !strcmp(de->d_name+1+conffbasenamelen,"#"))
+            strncmp(de->d_name + 1, conffbasename, conffbasenamelen) == 0 &&
+            strcmp(de->d_name + 1 + conffbasenamelen, "#") == 0)
           goto yes_remove;
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry not it");
         continue;

+ 2 - 2
src/trigcmd.c

@@ -144,7 +144,7 @@ parse_awaiter_package(void)
 static void
 tdm_add_trig_begin(const char *trig)
 {
-	ctrig = !strcmp(trig, activate);
+	ctrig = strcmp(trig, activate) == 0;
 	trigdef_update_printf("%s", trig);
 	if (!ctrig || done_trig)
 		return;
@@ -155,7 +155,7 @@ tdm_add_trig_begin(const char *trig)
 static void
 tdm_add_package(const char *awname)
 {
-	if (ctrig && !strcmp(awname, bypackage))
+	if (ctrig && strcmp(awname, bypackage) == 0)
 		return;
 	yespackage(awname);
 }

+ 1 - 1
src/trigproc.c

@@ -244,7 +244,7 @@ check_trigger_cycle(struct pkginfo *processing_now)
 				      " tortoisetrig=%s haretrig=%s",
 				      processing_now_name, tortoise_name,
 				      tortoise_trig->name, hare_trig->name);
-				if (!strcmp(hare_trig->name, tortoise_trig->name))
+				if (strcmp(hare_trig->name, tortoise_trig->name) == 0)
 					goto found_in_hare;
 			}
 			/* Not found in hare, yay! */

+ 1 - 1
utils/start-stop-daemon.c

@@ -667,7 +667,7 @@ parse_schedule_item(const char *string, struct schedule_item *item)
 {
 	const char *after_hyph;
 
-	if (!strcmp(string, "forever")) {
+	if (strcmp(string, "forever") == 0) {
 		item->type = sched_forever;
 	} else if (isdigit(string[0])) {
 		item->type = sched_timeout;