Преглед изворни кода

libdpkg: Fix redundant compression error messages

Avoid ohshite() except where errno is useful. This should avoid
confusing error messages like:

        data: internal gzip error: read: stream error: Success

While we're at it, drop the number of bytes read and written from
the read() != write() error message and output the error message
from the compression library instead.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Guillem Jover <guillem@debian.org>
Jonathan Nieder пре 16 година
родитељ
комит
fcf68d7115
1 измењених фајлова са 8 додато и 12 уклоњено
  1. 8 12
      lib/dpkg/compress.c

+ 8 - 12
lib/dpkg/compress.c

@@ -84,7 +84,7 @@ decompress_cat(enum compress_type type, int fd_in, int fd_out,
               if (errno == EINTR) continue;
               errmsg= strerror(errno);
             }
-          ohshite(_("%s: internal gzip error: `%s'"), v.buf, errmsg);
+            ohshit(_("%s: internal gzip read error: '%s'"), v.buf, errmsg);
           }
           write(fd_out,buffer,actualread);
         }
@@ -107,7 +107,7 @@ decompress_cat(enum compress_type type, int fd_in, int fd_out,
               if (errno == EINTR) continue;
               errmsg= strerror(errno);
             }
-          ohshite(_("%s: internal bzip2 error: `%s'"), v.buf, errmsg);
+            ohshit(_("%s: internal bzip2 read error: '%s'"), v.buf, errmsg);
           }
           write(fd_out,buffer,actualread);
         }
@@ -155,20 +155,18 @@ compress_cat(enum compress_type type, int fd_in, int fd_out,
         while ((actualread = read(fd_in, buffer, sizeof(buffer))) > 0) {
           if (actualread < 0 ) {
             if (errno == EINTR) continue;
-            ohshite(_("%s: internal gzip error: read: `%s'"), v.buf, strerror(errno));
+            ohshite(_("%s: internal gzip read error"), v.buf);
           }
           actualwrite= gzwrite(gzfile,buffer,actualread);
-          if (actualwrite < 0 ) {
+          if (actualwrite != actualread) {
             int err = 0;
             const char *errmsg = gzerror(gzfile, &err);
             if (err == Z_ERRNO) {
               if (errno == EINTR) continue;
             errmsg= strerror(errno);
             }
-            ohshite(_("%s: internal gzip error: write: `%s'"), v.buf, errmsg);
+            ohshit(_("%s: internal gzip write error: '%s'"), v.buf, errmsg);
           }
-          if (actualwrite != actualread)
-            ohshite(_("%s: internal gzip error: read(%i) != write(%i)"), v.buf, actualread, actualwrite);
         }
         gzclose(gzfile);
         exit(0);
@@ -190,20 +188,18 @@ compress_cat(enum compress_type type, int fd_in, int fd_out,
         while ((actualread = read(fd_in, buffer, sizeof(buffer))) > 0) {
           if (actualread < 0 ) {
             if (errno == EINTR) continue;
-            ohshite(_("%s: internal bzip2 error: read: `%s'"), v.buf, strerror(errno));
+            ohshite(_("%s: internal bzip2 read error"), v.buf);
           }
           actualwrite= BZ2_bzwrite(bzfile,buffer,actualread);
-          if (actualwrite < 0 ) {
+          if (actualwrite != actualread) {
             int err = 0;
             const char *errmsg = BZ2_bzerror(bzfile, &err);
             if (err == BZ_IO_ERROR) {
               if (errno == EINTR) continue;
               errmsg= strerror(errno);
             }
-            ohshite(_("%s: internal bzip2 error: write: `%s'"), v.buf, errmsg);
+            ohshit(_("%s: internal bzip2 write error: '%s'"), v.buf, errmsg);
           }
-          if (actualwrite != actualread)
-            ohshite(_("%s: internal bzip2 error: read(%i) != write(%i)"), v.buf, actualread, actualwrite);
         }
         BZ2_bzclose(bzfile);
         exit(0);