Quellcode durchsuchen

dpkg-split: Get rid of global partqueue queue variable

Change scandepot() to return the queue, and discard_parts() to take it
as argument.
Guillem Jover vor 12 Jahren
Ursprung
Commit
b17bf8bef6
5 geänderte Dateien mit 19 neuen und 14 gelöschten Zeilen
  1. 1 0
      debian/changelog
  2. 0 2
      dpkg-split/dpkg-split.h
  3. 1 1
      dpkg-split/join.c
  4. 0 2
      dpkg-split/main.c
  5. 17 9
      dpkg-split/queue.c

+ 1 - 0
debian/changelog

@@ -9,6 +9,7 @@ dpkg (1.17.4) UNRELEASED; urgency=low
   * Reset the statoverrides information from the in-core database when
     reloading it from disk, otherwise removals in maintainer scripts will
     not be seen during the current dpkg run.
+  * Get rid of dpkg-split global partqueue queue variable.
 
  -- Guillem Jover <guillem@debian.org>  Thu, 05 Dec 2013 11:08:49 +0100
 

+ 0 - 2
dpkg-split/dpkg-split.h

@@ -57,8 +57,6 @@ struct partqueue {
   struct partinfo info;
 };
 
-extern struct partqueue *queue;
-
 extern off_t opt_maxpartsize;
 extern const char *opt_depotdir;
 extern const char *opt_outputfile;

+ 1 - 1
dpkg-split/join.c

@@ -101,11 +101,11 @@ int
 do_join(const char *const *argv)
 {
   const char *thisarg;
+  struct partqueue *queue = NULL;
   struct partqueue *pq;
   struct partinfo *refi, **partlist;
   unsigned int i;
 
-  assert(!queue);
   if (!*argv)
     badusage(_("--%s requires one or more part file arguments"),
              cipaction->olong);

+ 0 - 2
dpkg-split/main.c

@@ -103,8 +103,6 @@ usage(const struct cmdinfo *cip, const char *value)
 
 static const char printforhelp[] = N_("Type dpkg-split --help for help.");
 
-struct partqueue *queue= NULL;
-
 off_t opt_maxpartsize = SPLITPARTDEFMAX;
 static const char *admindir;
 const char *opt_depotdir;

+ 17 - 9
dpkg-split/queue.c

@@ -83,13 +83,13 @@ decompose_filename(const char *filename, struct partqueue *pq)
   return true;
 }
 
-static void
+static struct partqueue *
 scandepot(void)
 {
   DIR *depot;
   struct dirent *de;
+  struct partqueue *queue = NULL;
 
-  assert(!queue);
   depot = opendir(opt_depotdir);
   if (!depot)
     ohshite(_("unable to read depot directory `%.250s'"), opt_depotdir);
@@ -117,6 +117,8 @@ scandepot(void)
     queue= pq;
   }
   closedir(depot);
+
+  return queue;
 }
 
 static bool
@@ -133,6 +135,7 @@ do_auto(const char *const *argv)
 {
   const char *partfile;
   struct partinfo *refi, **partlist, *otherthispart;
+  struct partqueue *queue;
   struct partqueue *pq;
   unsigned int i;
   int j;
@@ -154,7 +157,8 @@ do_auto(const char *const *argv)
     return 1;
   }
   fclose(part);
-  scandepot();
+
+  queue = scandepot();
   partlist= nfmalloc(sizeof(struct partinfo*)*refi->maxpartn);
   for (i = 0; i < refi->maxpartn; i++)
     partlist[i] = NULL;
@@ -235,6 +239,7 @@ do_auto(const char *const *argv)
 int
 do_queue(const char *const *argv)
 {
+  struct partqueue *queue;
   struct partqueue *pq;
   const char *head;
   struct stat stab;
@@ -242,7 +247,8 @@ do_queue(const char *const *argv)
 
   if (*argv)
     badusage(_("--%s takes no arguments"), cipaction->olong);
-  scandepot();
+
+  queue = scandepot();
 
   head= N_("Junk files left around in the depot directory:\n");
   for (pq= queue; pq; pq= pq->nextinqueue) {
@@ -301,7 +307,8 @@ enum discard_which {
 };
 
 static void
-discard_parts(enum discard_which which, const char *package)
+discard_parts(struct partqueue *queue, enum discard_which which,
+              const char *package)
 {
   struct partqueue *pq;
 
@@ -328,18 +335,19 @@ int
 do_discard(const char *const *argv)
 {
   const char *thisarg;
+  struct partqueue *queue;
   struct partqueue *pq;
 
-  scandepot();
+  queue = scandepot();
   if (*argv) {
     for (pq= queue; pq; pq= pq->nextinqueue)
       if (pq->info.md5sum)
         mustgetpartinfo(pq->info.filename,&pq->info);
-    discard_parts(ds_junk, null);
+    discard_parts(queue, ds_junk, NULL);
     while ((thisarg = *argv++))
-      discard_parts(ds_package, thisarg);
+      discard_parts(queue, ds_package, thisarg);
   } else {
-    discard_parts(ds_all, NULL);
+    discard_parts(queue, ds_all, NULL);
   }
 
   return 0;