Przeglądaj źródła

libdpkg: Make warning() not implicitly print the errno string

The callers who want the errno string should call strerror().
Guillem Jover 17 lat temu
rodzic
commit
decb92e453
3 zmienionych plików z 8 dodań i 4 usunięć
  1. 5 0
      ChangeLog
  2. 1 3
      lib/ehandle.c
  3. 2 1
      lib/myopt.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-12-05  Guillem Jover  <guillem@debian.org>
+
+	* lib/ehandle.c (warning): Do not implicitly print the errno string.
+	* lib/myopt.c (myfileopt): Print the errno string in the warning.
+
 2008-12-05  Guillem Jover  <guillem@debian.org>
 
 	* lib/dpkg.h (warningf): Rename to ...

+ 1 - 3
lib/ehandle.c

@@ -292,16 +292,14 @@ void ohshite(const char *fmt, ...) {
 void
 warning(const char *fmt, ...)
 {
-  int e;
   va_list al;
   char buf[1024];
 
-  e=errno;
   va_start(al,fmt);
   vsnprintf(buf,sizeof(buf),fmt,al);
   va_end(al);
 
-  fprintf(stderr,"%s: %s\n",buf,strerror(e));
+  fprintf(stderr, "%s\n", buf);
 }
 
 void badusage(const char *fmt, ...) {

+ 2 - 1
lib/myopt.c

@@ -40,7 +40,8 @@ void myfileopt(const char* fn, const struct cmdinfo* cmdinfos) {
   if (!file) {
     if (errno==ENOENT)
       return;
-    warning(_("failed to open configuration file `%.255s' for reading"), fn);
+    warning(_("failed to open configuration file '%.255s' for reading: %s"),
+            fn, strerror(errno));
     return;
   }