diff options
author | Guillem Jover <guillem@debian.org> | 2013-11-22 21:20:55 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2013-12-07 07:43:21 +0100 |
commit | b17bf8bef6c446b8fe97a88f189c1ccbe5ab094d (patch) | |
tree | 13a9b703b3b7be0364c186763b010048cd121dd3 /dpkg-split | |
parent | e6962f426e1d246e8c54a1780eb2d7a570382136 (diff) | |
download | dpkg-b17bf8bef6c446b8fe97a88f189c1ccbe5ab094d.tar.gz |
dpkg-split: Get rid of global partqueue queue variable
Change scandepot() to return the queue, and discard_parts() to take it
as argument.
Diffstat (limited to 'dpkg-split')
-rw-r--r-- | dpkg-split/dpkg-split.h | 2 | ||||
-rw-r--r-- | dpkg-split/join.c | 2 | ||||
-rw-r--r-- | dpkg-split/main.c | 2 | ||||
-rw-r--r-- | dpkg-split/queue.c | 26 |
4 files changed, 18 insertions, 14 deletions
diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h index a22b09c7c..6941b51eb 100644 --- a/dpkg-split/dpkg-split.h +++ b/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; diff --git a/dpkg-split/join.c b/dpkg-split/join.c index 660b34640..c2ac5b1ac 100644 --- a/dpkg-split/join.c +++ b/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); diff --git a/dpkg-split/main.c b/dpkg-split/main.c index 192e79ebe..18f7f7834 100644 --- a/dpkg-split/main.c +++ b/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; diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c index 4b26e3a89..ca8080fd8 100644 --- a/dpkg-split/queue.c +++ b/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; |