Просмотр исходного кода

Do not assign to variables when they subsequently get overwritten

This was spotted by a run with the clang static analyzer.
Guillem Jover лет назад: 16
Родитель
Сommit
80647e33d1
5 измененных файлов с 6 добавлено и 8 удалено
  1. 2 3
      dpkg-deb/info.c
  2. 2 2
      lib/dpkg/buffer.c
  3. 0 1
      lib/dpkg/tarfn.c
  4. 1 1
      src/archives.c
  5. 1 1
      src/main.c

+ 2 - 3
dpkg-deb/info.c

@@ -146,8 +146,8 @@ static void info_list(const char *debar, const char *directory) {
         ohshite(_("cannot open `%.255s' (in `%.255s')"),cdep->d_name,directory);
       lines = 0;
       interpreter[0] = '\0';
-      if ((c= getc(cc))== '#') {
-        if ((c= getc(cc))== '!') {
+      if (getc(cc) == '#') {
+        if (getc(cc) == '!') {
           while ((c= getc(cc))== ' ');
           p=interpreter; *p++='#'; *p++='!'; il=2;
           while (il<INTERPRETER_MAX && !isspace(c) && c!=EOF) {
@@ -200,7 +200,6 @@ static void info_field(const char *debar, const char *directory,
     c= getc(cc);  if (c==EOF) { doing=0; break; }
     if (c == '\n') { lno++; doing=1; continue; }
     if (!isspace(c)) {
-      doing= 0;
       for (pf=fieldname, fnl=0;
            fnl <= MAXFIELDNAME && c!=EOF && !isspace(c) && c!=':';
            c= getc(cc)) { *pf++= c; fnl++; }

+ 2 - 2
lib/dpkg/buffer.c

@@ -138,7 +138,7 @@ off_t
 buffer_read(struct buffer_data *data, void *buf, off_t length,
             const char *desc)
 {
-	off_t ret = length;
+	off_t ret;
 
 	switch (data->type) {
 	case BUFFER_READ_FD:
@@ -222,7 +222,7 @@ buffer_copy(struct buffer_data *read_data, struct buffer_data *write_data,
 	if (bufsize == 0)
 		return 0;
 
-	writebuf = buf = m_malloc(bufsize);
+	buf = m_malloc(bufsize);
 
 	while (bytesread >= 0 && byteswritten >= 0 && bufsize > 0) {
 		bytesread = buffer_read(read_data, buf, bufsize, desc);

+ 0 - 1
lib/dpkg/tarfn.c

@@ -190,7 +190,6 @@ TarExtractor(void *userData, const TarFunctions *functions)
 
 	next_long_name = NULL;
 	next_long_link = NULL;
-	long_read = 0;
 	symlink_tail = symlink_node = symlink_head = m_malloc(sizeof(symlinkList));
 	symlink_head->next = NULL;
 

+ 1 - 1
src/archives.c

@@ -1130,7 +1130,7 @@ void archivefiles(const char *const *argv) {
     p= findoutput.buf; i=0;
     while (*p) {
       arglist[i++]= p;
-      while ((c = *p++) != '\0') ;
+      while (*p++ != '\0') ;
     }
     arglist[i] = NULL;
     argp= arglist;

+ 1 - 1
src/main.c

@@ -619,7 +619,7 @@ void commandfd(const char *const *argv) {
     error_unwind(ehflag_bombout); exit(2);
   }
 
-  for (;;lno= 0) {
+  for (;;) {
     const char **oldargs= NULL;
     int argc= 1, mode= 0;
     lno= 0;