Parcourir la source

Do not increment variables when the value is not going to be used

This was spotted by a run with the clang static analyzer.
Guillem Jover il y a 16 ans
Parent
commit
a29c9c8700
2 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 2 2
      dpkg-deb/info.c
  2. 1 1
      src/archives.c

+ 2 - 2
dpkg-deb/info.c

@@ -153,7 +153,7 @@ static void info_list(const char *debar, const char *directory) {
           while (il<INTERPRETER_MAX && !isspace(c) && c!=EOF) {
             *p++= c; il++; c= getc(cc);
           }
-          *p++ = '\0';
+          *p = '\0';
           if (c=='\n') lines++;
         }
       }
@@ -203,7 +203,7 @@ static void info_field(const char *debar, const char *directory,
       for (pf=fieldname, fnl=0;
            fnl <= MAXFIELDNAME && c!=EOF && !isspace(c) && c!=':';
            c= getc(cc)) { *pf++= c; fnl++; }
-      *pf++ = '\0';
+      *pf = '\0';
       doing= fnl >= MAXFIELDNAME || c=='\n' || c==EOF;
       for (fp=fields; !doing && *fp; fp++)
         if (!strcasecmp(*fp,fieldname)) doing=1;

+ 1 - 1
src/archives.c

@@ -1101,7 +1101,7 @@ void archivefiles(const char *const *argv) {
       arglist[i++] = "-type";
       arglist[i++] = "f";
       arglist[i++] = "-print0";
-      arglist[i++] = NULL;
+      arglist[i] = NULL;
       execvp(FIND, (char *const *)arglist);
       ohshite(_("failed to exec find for --recursive"));
     }