Kaynağa Gözat

dpkg-query: stop needlessly using functionality from error.c

The file was being pulled only because dpkg-query was using nerrs.
Guillem Jover 18 yıl önce
ebeveyn
işleme
f40b311b75
5 değiştirilmiş dosya ile 20 ekleme ve 12 silme
  1. 13 0
      ChangeLog
  2. 0 1
      src/Makefile.am
  3. 1 1
      src/errors.c
  4. 0 1
      src/main.h
  5. 6 9
      src/query.c

+ 13 - 0
ChangeLog

@@ -1,3 +1,16 @@
+2008-10-15  Guillem Jover  <guillem@debian.org>
+
+	* src/Makefile.am (dpkg_query_SOURCES): Remove 'errors.c'.
+	* src/main.h (nerrs): Remove declaration.
+	* src/errors.c (nerrs): Change from extern to static.
+	* src/query.c (failures): New variable.
+	(errabort): Remove variable.
+	(listpackages): Use failures instead of nerrs.
+	(searchfiles): Likewise.
+	(showpackages): Likewise.
+	(enqperpackage): Likewise. Do not define nor initialize failures.
+	(main): Use failures variable instead of reportbroken_retexitstatus.
+
 2008-09-14  Guillem Jover  <guillem@debian.org>
 
 	* libcompat/scandir.c (scandir): Handle case when filter and cmp

+ 0 - 1
src/Makefile.am

@@ -38,7 +38,6 @@ dpkg_LDADD = \
 	$(SELINUX_LIBS)
 
 dpkg_query_SOURCES = \
-	errors.c \
 	filesdb.c filesdb.h \
 	pkg-list.c \
 	pkg-show.c \

+ 1 - 1
src/errors.c

@@ -42,7 +42,7 @@
 
 #include "main.h"
 
-int nerrs= 0;
+static int nerrs = 0;
 
 struct error_report {
   struct error_report *next;

+ 0 - 1
src/main.h

@@ -182,7 +182,6 @@ void cu_prermremove(int argc, void **argv);
 
 /* from errors.c */
 
-extern int nerrs;
 void print_error_perpackage(const char *emsg, const char *arg);
 void forcibleerr(int forceflag, const char *format, ...) PRINTFFORMAT(2,3);
 int reportbroken_retexitstatus(void);

+ 6 - 9
src/query.c

@@ -48,6 +48,7 @@
 #include "filesdb.h"
 #include "main.h"
 
+static int failures = 0;
 static const char* showformat		= "${Package}\t${Version}\n";
 
 static int getwidth(void) {
@@ -180,7 +181,7 @@ void listpackages(const char *const *argv) {
     for (ip = 0; ip < argc; ip++) {
       if (!found[ip]) {
         fprintf(stderr, _("No packages found matching %s.\n"), argv[ip]);
-        nerrs++;
+        failures++;
       }
     }
   }
@@ -275,7 +276,7 @@ void searchfiles(const char *const *argv) {
     }
     if (!found) {
       fprintf(stderr,_("dpkg: %s not found.\n"),thisarg);
-      nerrs++;
+      failures++;
       if (ferror(stderr)) werr("stderr");
     } else {
       if (ferror(stdout)) werr("stdout");
@@ -287,7 +288,6 @@ void searchfiles(const char *const *argv) {
 }
 
 void enqperpackage(const char *const *argv) {
-  int failures;
   const char *thisarg;
   struct fileinlist *file;
   struct pkginfo *pkg;
@@ -296,7 +296,6 @@ void enqperpackage(const char *const *argv) {
   if (!*argv)
     badusage(_("--%s needs at least one package name argument"), cipaction->olong);
 
-  failures= 0;
   if (cipaction->arg==act_listfiles)
     modstatdb_init(admindir,msdbrw_readonly|msdbrw_noavail);
   else 
@@ -376,7 +375,6 @@ void enqperpackage(const char *const *argv) {
   }
 
   if (failures) {
-    nerrs++;
     fputs(_("Use dpkg --info (= dpkg-deb --info) to examine archive files,\n"
          "and dpkg --contents (= dpkg-deb --contents) to list their contents.\n"),stderr);
     if (ferror(stdout)) werr("stdout");
@@ -392,7 +390,7 @@ void showpackages(const char *const *argv) {
   struct lstitem* fmt = parseformat(showformat);
 
   if (!fmt) {
-    nerrs++;
+    failures++;
     return;
   }
 
@@ -439,7 +437,7 @@ void showpackages(const char *const *argv) {
     for (ip = 0; ip < argc; ip++) {
       if (!found[ip]) {
         fprintf(stderr, _("No packages found matching %s.\n"), argv[ip]);
-        nerrs++;
+        failures++;
       }
     }
   }
@@ -517,7 +515,6 @@ int fc_hold=0;
 int fc_conflicts=0, fc_depends=0;
 int fc_badpath=0;
 
-int errabort = 50;
 const char *admindir= ADMINDIR;
 const char *instdir= "";
 
@@ -578,5 +575,5 @@ int main(int argc, const char *const *argv) {
 
   standard_shutdown();
 
-  return reportbroken_retexitstatus();
+  return !!failures;
 }