[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH 03/15] 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>
---
 lib/dpkg/compression.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/lib/dpkg/compression.c b/lib/dpkg/compression.c
index 22e1af7..c80a9b1 100644
--- a/lib/dpkg/compression.c
+++ b/lib/dpkg/compression.c
@@ -52,7 +52,8 @@ fd_fd_filter(int fd_in, int fd_out,
           continue; \
         errmsg = strerror(errno); \
       } \
-      ohshite(_("%s: internal " format " error: `%s'"), desc, errmsg); \
+      ohshit(_("%s: internal " format " error: %s: %s"), \
+             desc, "read", errmsg); \
     } \
     write(fd_out, buffer, actualread); \
   } \
@@ -74,11 +75,11 @@ fd_fd_filter(int fd_in, int fd_out,
     if (actualread < 0) { \
       if (errno == EINTR) \
         continue; \
-      ohshite(_("%s: internal " format " error: read: `%s'"), \
-              desc, strerror(errno)); \
+      ohshite(_("%s: internal " format " error: %s"), \
+              desc, "read"); \
     } \
     actualwrite = zwrite(zfile, buffer, actualread); \
-    if (actualwrite < 0) { \
+    if (actualwrite != actualread) { \
       int err = 0; \
       const char *errmsg = zerror(zfile, &err); \
       if (err == ERR_ERRNO) { \
@@ -86,12 +87,9 @@ fd_fd_filter(int fd_in, int fd_out,
           continue; \
         errmsg = strerror(errno); \
       } \
-      ohshite(_("%s: internal " format " error: write: `%s'"), \
-              desc, errmsg); \
+      ohshit(_("%s: internal " format " error: %s: %s"), \
+              desc, "write", errmsg); \
     } \
-    if (actualwrite != actualread) \
-      ohshite(_("%s: internal " format " error: read(%i) != write(%i)"), \
-              desc, actualread, actualwrite); \
   } \
   zclose(zfile); \
   exit(0); \
-- 
1.6.5.rc1.199.g596ec


Reply to: