Просмотр исходного кода

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 лет назад: 12
Родитель
Сommit
b17bf8bef6
5 измененных файлов с 19 добавлено и 14 удалено
  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
   * Reset the statoverrides information from the in-core database when
     reloading it from disk, otherwise removals in maintainer scripts will
     reloading it from disk, otherwise removals in maintainer scripts will
     not be seen during the current dpkg run.
     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
  -- 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;
   struct partinfo info;
 };
 };
 
 
-extern struct partqueue *queue;
-
 extern off_t opt_maxpartsize;
 extern off_t opt_maxpartsize;
 extern const char *opt_depotdir;
 extern const char *opt_depotdir;
 extern const char *opt_outputfile;
 extern const char *opt_outputfile;

+ 1 - 1
dpkg-split/join.c

@@ -101,11 +101,11 @@ int
 do_join(const char *const *argv)
 do_join(const char *const *argv)
 {
 {
   const char *thisarg;
   const char *thisarg;
+  struct partqueue *queue = NULL;
   struct partqueue *pq;
   struct partqueue *pq;
   struct partinfo *refi, **partlist;
   struct partinfo *refi, **partlist;
   unsigned int i;
   unsigned int i;
 
 
-  assert(!queue);
   if (!*argv)
   if (!*argv)
     badusage(_("--%s requires one or more part file arguments"),
     badusage(_("--%s requires one or more part file arguments"),
              cipaction->olong);
              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.");
 static const char printforhelp[] = N_("Type dpkg-split --help for help.");
 
 
-struct partqueue *queue= NULL;
-
 off_t opt_maxpartsize = SPLITPARTDEFMAX;
 off_t opt_maxpartsize = SPLITPARTDEFMAX;
 static const char *admindir;
 static const char *admindir;
 const char *opt_depotdir;
 const char *opt_depotdir;

+ 17 - 9
dpkg-split/queue.c

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