diff options
author | Guillem Jover <guillem@debian.org> | 2018-01-13 02:37:02 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2018-08-30 03:14:08 +0200 |
commit | c7c948d8b9ed774163d35c573f25029d69e45348 (patch) | |
tree | 54cefcd327dfbddc3b4db537378aa1b3e5fe02e7 /src | |
parent | ae6a3ddd2a774ee1cedc5ee0c87ab8c66ae5f786 (diff) | |
download | dpkg-c7c948d8b9ed774163d35c573f25029d69e45348.tar.gz |
libdpkg: Split push_cleanup() into push_cleanup_fallback()
We separate the function in one that takes one callback, and another
that takes two. This simplifies most of the call sites which only need
one callback.
Diffstat (limited to 'src')
-rw-r--r-- | src/archives.c | 4 | ||||
-rw-r--r-- | src/configure.c | 2 | ||||
-rw-r--r-- | src/divertcmd.c | 2 | ||||
-rw-r--r-- | src/remove.c | 4 | ||||
-rw-r--r-- | src/script.c | 2 | ||||
-rw-r--r-- | src/unpack.c | 32 |
6 files changed, 23 insertions, 23 deletions
diff --git a/src/archives.c b/src/archives.c index 4c5fb8897..e802baaee 100644 --- a/src/archives.c +++ b/src/archives.c @@ -362,7 +362,7 @@ tarobject_extract(struct tarcontext *tc, struct tar_entry *te, if (fd < 0) ohshite(_("unable to create '%.255s' (while processing '%.255s')"), path, te->name); - push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd); + push_cleanup(cu_closefd, ehflag_bombout, 1, &fd); debug(dbg_eachfiledetail, "tarobject file open size=%jd", (intmax_t)te->size); @@ -965,7 +965,7 @@ tarobject(void *ctx, struct tar_entry *ti) /* Now we start to do things that we need to be able to undo * if something goes wrong. Watch out for the CLEANUP comments to * keep an eye on what's installed on the disk at each point. */ - push_cleanup(cu_installnew, ~ehflag_normaltidy, NULL, 0, 1, nifd->namenode); + push_cleanup(cu_installnew, ~ehflag_normaltidy, 1, nifd->namenode); /* * CLEANUP: Now we either have the old file on the disk, or not, in diff --git a/src/configure.c b/src/configure.c index 2d9173eba..076abbd9d 100644 --- a/src/configure.c +++ b/src/configure.c @@ -831,7 +831,7 @@ md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn) fd = open(fn, O_RDONLY); if (fd >= 0) { - push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd); + push_cleanup(cu_closefd, ehflag_bombout, 1, &fd); if (fd_md5(fd, hashbuf, -1, &err) < 0) ohshit(_("cannot compute MD5 hash for file '%s': %s"), fn, err.str); diff --git a/src/divertcmd.c b/src/divertcmd.c index d50409d02..69d187c45 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -232,7 +232,7 @@ file_copy(const char *src, const char *dst) if (dstfd < 0) ohshite(_("unable to create file '%s'"), tmp); - push_cleanup(cu_filename, ~ehflag_normaltidy, NULL, 0, 1, tmp); + push_cleanup(cu_filename, ~ehflag_normaltidy, 1, tmp); if (fd_fd_copy(srcfd, dstfd, -1, &err) < 0) ohshit(_("cannot copy '%s' to '%s': %s"), src, tmp, err.str); diff --git a/src/remove.c b/src/remove.c index 18d470aea..fb27341f6 100644 --- a/src/remove.c +++ b/src/remove.c @@ -189,7 +189,7 @@ void deferred_remove(struct pkginfo *pkg) { oldpkgstatus= pkg->status; pkg_set_status(pkg, PKG_STAT_HALFCONFIGURED); modstatdb_note(pkg); - push_cleanup(cu_prermremove, ~ehflag_normaltidy, NULL, 0, 2, + push_cleanup(cu_prermremove, ~ehflag_normaltidy, 2, (void *)pkg, (void *)&oldpkgstatus); maintscript_installed(pkg, PRERMFILE, "pre-removal", "remove", NULL); @@ -564,7 +564,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) { fnvb.buf, conff->name); } debug(dbg_conffdetail, "removal_bulk conffile cleaning dsd %s", fnvb.buf); - push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd); + push_cleanup(cu_closedir, ~0, 1, (void *)dsd); *p= '/'; conffbasenamelen= strlen(++p); conffbasename= fnvb.buf+conffnameused-conffbasenamelen; diff --git a/src/script.c b/src/script.c index fc6f6117e..9c8585b64 100644 --- a/src/script.c +++ b/src/script.c @@ -171,7 +171,7 @@ maintscript_exec(struct pkginfo *pkg, struct pkgbin *pkgbin, setexecute(cmd->filename, stab); - push_cleanup(cu_post_script_tasks, ehflag_bombout, NULL, 0, 0); + push_cleanup(cu_post_script_tasks, ehflag_bombout, 0); pid = subproc_fork(); if (pid == 0) { diff --git a/src/unpack.c b/src/unpack.c index cae756222..a42d0f7fa 100644 --- a/src/unpack.c +++ b/src/unpack.c @@ -94,7 +94,7 @@ deb_reassemble(const char **filename, const char **pfilename) if (unlink(reasmbuf) && errno != ENOENT) ohshite(_("error ensuring '%.250s' doesn't exist"), reasmbuf); - push_cleanup(cu_pathname, ~0, NULL, 0, 1, (void *)reasmbuf); + push_cleanup(cu_pathname, ~0, 1, (void *)reasmbuf); pid = subproc_fork(); if (!pid) { @@ -291,9 +291,9 @@ pkg_deconfigure_others(struct pkginfo *pkg) /* This means that we *either* go and run postinst abort-deconfigure, * *or* queue the package for later configure processing, depending * on which error cleanup route gets taken. */ - push_cleanup(cu_prermdeconfigure, ~ehflag_normaltidy, - ok_prermdeconfigure, ehflag_normaltidy, - 3, (void *)deconpil->pkg, (void *)removing, (void *)pkg); + push_cleanup_fallback(cu_prermdeconfigure, ~ehflag_normaltidy, + ok_prermdeconfigure, ehflag_normaltidy, + 3, (void *)deconpil->pkg, (void *)removing, (void *)pkg); if (removing) { maintscript_installed(deconpil->pkg, PRERMFILE, "pre-removal", @@ -334,7 +334,7 @@ deb_parse_conffiles(struct pkginfo *pkg, const char *control_conffiles, ohshite(_("error trying to open %.250s"), control_conffiles); } - push_cleanup(cu_closestream, ehflag_bombout, NULL, 0, 1, conff); + push_cleanup(cu_closestream, ehflag_bombout, 1, conff); while (fgets(conffilenamebuf, MAXCONFFILENAME - 2, conff)) { struct pkginfo *otherpkg; @@ -495,7 +495,7 @@ pkg_infodb_update(struct pkginfo *pkg, char *cidir, char *cidirrest) dsd = opendir(cidir); if (!dsd) ohshite(_("unable to open temp control directory")); - push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd); + push_cleanup(cu_closedir, ~0, 1, (void *)dsd); while ((de = readdir(dsd))) { const char *newinfofilename; @@ -1110,7 +1110,7 @@ void process_archive(const char *filename) { /* Get the control information directory. */ cidir = get_control_dir(cidir); cidirrest = cidir + strlen(cidir); - push_cleanup(cu_cidir, ~0, NULL, 0, 2, (void *)cidir, (void *)cidirrest); + push_cleanup(cu_cidir, ~0, 2, (void *)cidir, (void *)cidirrest); pid = subproc_fork(); if (pid == 0) { @@ -1221,7 +1221,7 @@ void process_archive(const char *filename) { /* Read the conffiles, and copy the hashes across. */ newconffiles.head = NULL; newconffiles.tail = &newconffiles.head; - push_cleanup(cu_fileslist, ~0, NULL, 0, 0); + push_cleanup(cu_fileslist, ~0, 0); strcpy(cidirrest,CONFFILESFILE); deb_parse_conffiles(pkg, cidir, &newconffiles); @@ -1249,7 +1249,7 @@ void process_archive(const char *filename) { pkg_set_eflags(pkg, PKG_EFLAG_REINSTREQ); pkg_set_status(pkg, PKG_STAT_HALFCONFIGURED); modstatdb_note(pkg); - push_cleanup(cu_prermupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg); + push_cleanup(cu_prermupgrade, ~ehflag_normaltidy, 1, (void *)pkg); if (dpkg_version_compare(&pkg->available.version, &pkg->installed.version) >= 0) /* Upgrade or reinstall. */ @@ -1282,7 +1282,7 @@ void process_archive(const char *filename) { trig_activate_packageprocessing(conflictor); pkg_set_status(conflictor, PKG_STAT_HALFCONFIGURED); modstatdb_note(conflictor); - push_cleanup(cu_prerminfavour, ~ehflag_normaltidy, NULL, 0, + push_cleanup(cu_prerminfavour, ~ehflag_normaltidy, 2, conflictor, pkg); maintscript_installed(conflictor, PRERMFILE, "pre-removal", "remove", "in-favour", @@ -1302,12 +1302,12 @@ void process_archive(const char *filename) { pkg_set_status(pkg, PKG_STAT_HALFINSTALLED); modstatdb_note(pkg); if (oldversionstatus == PKG_STAT_NOTINSTALLED) { - push_cleanup(cu_preinstverynew, ~ehflag_normaltidy, NULL, 0, + push_cleanup(cu_preinstverynew, ~ehflag_normaltidy, 3,(void*)pkg,(void*)cidir,(void*)cidirrest); maintscript_new(pkg, PREINSTFILE, "pre-installation", cidir, cidirrest, "install", NULL); } else if (oldversionstatus == PKG_STAT_CONFIGFILES) { - push_cleanup(cu_preinstnew, ~ehflag_normaltidy, NULL, 0, + push_cleanup(cu_preinstnew, ~ehflag_normaltidy, 3,(void*)pkg,(void*)cidir,(void*)cidirrest); maintscript_new(pkg, PREINSTFILE, "pre-installation", cidir, cidirrest, "install", @@ -1315,7 +1315,7 @@ void process_archive(const char *filename) { versiondescribe(&pkg->available.version, vdew_nonambig), NULL); } else { - push_cleanup(cu_preinstupgrade, ~ehflag_normaltidy, NULL, 0, + push_cleanup(cu_preinstupgrade, ~ehflag_normaltidy, 4,(void*)pkg,(void*)cidir,(void*)cidirrest,(void*)&oldversionstatus); maintscript_new(pkg, PREINSTFILE, "pre-installation", cidir, cidirrest, "upgrade", @@ -1412,7 +1412,7 @@ void process_archive(const char *filename) { */ m_pipe(p1); - push_cleanup(cu_closepipe, ehflag_bombout, NULL, 0, 1, (void *)&p1[0]); + push_cleanup(cu_closepipe, ehflag_bombout, 1, (void *)&p1[0]); pid = subproc_fork(); if (pid == 0) { m_dup2(p1[1],1); close(p1[0]); close(p1[1]); @@ -1426,7 +1426,7 @@ void process_archive(const char *filename) { newfiles_queue.head = NULL; newfiles_queue.tail = &newfiles_queue.head; tc.newfiles_queue = &newfiles_queue; - push_cleanup(cu_fileslist, ~0, NULL, 0, 0); + push_cleanup(cu_fileslist, ~0, 0); tc.pkg= pkg; tc.backendpipe= p1[0]; tc.pkgset_getting_in_sync = pkgset_getting_in_sync(pkg); @@ -1453,7 +1453,7 @@ void process_archive(const char *filename) { * reduced to ‘unpacked’ by now, by the running of the prerm script. */ pkg_set_status(pkg, PKG_STAT_HALFINSTALLED); modstatdb_note(pkg); - push_cleanup(cu_postrmupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg); + push_cleanup(cu_postrmupgrade, ~ehflag_normaltidy, 1, (void *)pkg); maintscript_fallback(pkg, POSTRMFILE, "post-removal", cidir, cidirrest, "upgrade", "failed-upgrade"); } |