diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/archives.c | 19 | ||||
-rw-r--r-- | src/configure.c | 5 | ||||
-rw-r--r-- | src/depcon.c | 13 | ||||
-rw-r--r-- | src/enquiry.c | 5 | ||||
-rw-r--r-- | src/filesdb.c | 10 | ||||
-rw-r--r-- | src/packages.c | 23 | ||||
-rw-r--r-- | src/script.c | 6 | ||||
-rw-r--r-- | src/trigproc.c | 15 | ||||
-rw-r--r-- | src/unpack.c | 18 |
9 files changed, 79 insertions, 35 deletions
diff --git a/src/archives.c b/src/archives.c index b82ee4f56..113b76c3d 100644 --- a/src/archives.c +++ b/src/archives.c @@ -29,7 +29,6 @@ #include <sys/time.h> #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <string.h> #include <time.h> @@ -631,7 +630,8 @@ linktosameexistingdir(const struct tar_entry *ti, const char *fname, varbuf_add_str(symlinkfn, instdir); } else { lastslash= strrchr(fname, '/'); - assert(lastslash); + if (lastslash == NULL) + internerr("tar entry filename '%s' does not contain '/'", fname); varbuf_add_buf(symlinkfn, fname, (lastslash - fname) + 1); } varbuf_add_str(symlinkfn, ti->linkname); @@ -1267,7 +1267,11 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg, char action[512]; ensure_package_clientdata(fixbydeconf); - assert(fixbydeconf->clientdata->istobe == PKG_ISTOBE_NORMAL); + + if (fixbydeconf->clientdata->istobe != PKG_ISTOBE_NORMAL) + internerr("package %s being fixed by deconf is not to be normal, " + "is to be %d", + pkg_name(pkg, pnaw_always), fixbydeconf->clientdata->istobe); sprintf(action, _("installation of %.250s"), pkgbin_name(pkg, &pkg->available, pnaw_nonambig)); @@ -1329,8 +1333,13 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg, fixbyrm->want != PKG_WANT_HOLD) || does_replace(pkg, &pkg->available, fixbyrm, &fixbyrm->installed)) && (!fixbyrm->installed.essential || fc_removeessential)))) { - assert(fixbyrm->clientdata->istobe == PKG_ISTOBE_NORMAL || - fixbyrm->clientdata->istobe == PKG_ISTOBE_DECONFIGURE); + + if (fixbyrm->clientdata->istobe != PKG_ISTOBE_NORMAL && + fixbyrm->clientdata->istobe != PKG_ISTOBE_DECONFIGURE) + internerr("package %s to be fixed by removal is not to be normal " + "nor deconfigure, is to be %d", + pkg_name(pkg, pnaw_always), fixbyrm->clientdata->istobe); + fixbyrm->clientdata->istobe = PKG_ISTOBE_REMOVE; notice(_("considering removing %s in favour of %s ..."), pkg_name(fixbyrm, pnaw_nonambig), diff --git a/src/configure.c b/src/configure.c index 815882425..3c565c61d 100644 --- a/src/configure.c +++ b/src/configure.c @@ -29,7 +29,6 @@ #include <sys/stat.h> #include <sys/wait.h> -#include <assert.h> #include <errno.h> #include <ctype.h> #include <string.h> @@ -681,7 +680,9 @@ deferred_configure(struct pkginfo *pkg) pkg_set_status(pkg, PKG_STAT_HALFCONFIGURED); } - assert(pkg->status == PKG_STAT_HALFCONFIGURED); + if (pkg->status != PKG_STAT_HALFCONFIGURED) + internerr("package %s in state %s, instead of half-configured", + pkg_name(pkg, pnaw_always), pkg_status_name(pkg)); modstatdb_note(pkg); diff --git a/src/depcon.c b/src/depcon.c index 924c53ac8..398d06a36 100644 --- a/src/depcon.c +++ b/src/depcon.c @@ -27,7 +27,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> @@ -314,10 +313,14 @@ depisok(struct dependency *dep, struct varbuf *whynot, * Allow 250x3 for package names, versions, &c, + 250 for ourselves. */ char linebuf[1024]; - assert(dep->type == dep_depends || dep->type == dep_predepends || - dep->type == dep_breaks || dep->type == dep_conflicts || - dep->type == dep_recommends || dep->type == dep_suggests || - dep->type == dep_enhances); + if (dep->type != dep_depends && + dep->type != dep_predepends && + dep->type != dep_breaks && + dep->type != dep_conflicts && + dep->type != dep_recommends && + dep->type != dep_suggests && + dep->type != dep_enhances) + internerr("unknown dependency type %d", dep->type); if (canfixbyremove) *canfixbyremove = NULL; diff --git a/src/enquiry.c b/src/enquiry.c index b299f841b..99349ba7c 100644 --- a/src/enquiry.c +++ b/src/enquiry.c @@ -26,7 +26,6 @@ #include <sys/types.h> -#include <assert.h> #include <string.h> #include <fcntl.h> #include <unistd.h> @@ -495,7 +494,9 @@ predeppackage(const char *const *argv) if (!dep) return 1; /* Not found. */ - assert(pkg); + if (pkg == NULL) + internerr("unexpected unfound package"); + startpkg= pkg; pkg->clientdata->istobe = PKG_ISTOBE_PREINSTALL; diff --git a/src/filesdb.c b/src/filesdb.c index 5050144e8..7f157727d 100644 --- a/src/filesdb.c +++ b/src/filesdb.c @@ -32,7 +32,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <string.h> #include <pwd.h> @@ -600,8 +599,13 @@ struct filenamenode *findnamenode(const char *name, enum fnnflags flags) { pointerp = bins + (str_fnv_hash(name) % (BINS)); while (*pointerp) { - /* XXX: Why is the assert needed? It's checking already added entries. */ - assert((*pointerp)->name[0] == '/'); + /* XXX: This should not be needed, but it has been a constant source + * of assertions over the years. Hopefully with the internerr() we will + * get better diagnostics. */ + if ((*pointerp)->name[0] != '/') + internerr("filename node '%s' does not start with '/'", + (*pointerp)->name); + if (strcmp((*pointerp)->name + 1, name) == 0) break; pointerp= &(*pointerp)->next; diff --git a/src/packages.c b/src/packages.c index f68c971ef..ae001757f 100644 --- a/src/packages.c +++ b/src/packages.c @@ -27,7 +27,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <string.h> #include <fcntl.h> #include <dirent.h> @@ -232,7 +231,9 @@ void process_queue(void) { * trigger processing, w/o jumping into the next dependtry. */ dependtry++; sincenothing = 0; - assert(dependtry <= 4); + if (dependtry > 4) + internerr("exceeded dependtry %d (sincenothing=%d; queue.length=%d)", + dependtry, sincenothing, queue.length); } else if (sincenothing > queue.length * 2 + 2) { /* XXX: This probably needs moving into a new dependtry instead. */ if (progress_bytrigproc && progress_bytrigproc->trigpend_head) { @@ -242,7 +243,9 @@ void process_queue(void) { } else { dependtry++; sincenothing = 0; - assert(dependtry <= 4); + if (dependtry > 4) + internerr("exceeded dependtry %d (sincenothing=%d, queue.length=%d)", + dependtry, sincenothing, queue.length); } } @@ -250,7 +253,8 @@ void process_queue(void) { pkg_name(pkg, pnaw_always), queue.length, sincenothing, dependtry); if (pkg->status > PKG_STAT_INSTALLED) - internerr("package status (%d) > PKG_STAT_INSTALLED", pkg->status); + internerr("package %s status %d is out-of-bounds", + pkg_name(pkg, pnaw_always), pkg->status); if (setjmp(ejbuf)) { /* Give up on it from the point of view of other packages, i.e. reset @@ -295,7 +299,10 @@ void process_queue(void) { pop_error_context(ehflag_normaltidy); } - assert(!queue.length); + + if (queue.length) + internerr("finished package processing with non-empty queue length %d", + queue.length); } /*** Dependency processing - common to --configure and --remove. ***/ @@ -424,7 +431,11 @@ deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby, return FOUND_OK; } if (possdependee->status == PKG_STAT_TRIGGERSAWAITED) { - assert(possdependee->trigaw.head); + if (possdependee->trigaw.head == NULL) + internerr("package %s in state %s, has no awaited triggers", + pkg_name(possdependee, pnaw_always), + pkg_status_name(possdependee)); + if (removing || !(f_triggers || possdependee->clientdata->istobe == PKG_ISTOBE_INSTALLNEW)) { diff --git a/src/script.c b/src/script.c index ac58779d1..ecf4a94a1 100644 --- a/src/script.c +++ b/src/script.c @@ -25,7 +25,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <string.h> #include <unistd.h> @@ -137,7 +136,10 @@ maintscript_pre_exec(struct command *cmd) if (instdirlen == 0 || fc_script_chrootless) return cmd->filename; - assert(strlen(cmd->filename) >= instdirlen); + if (strlen(cmd->filename) < instdirlen) + internerr("maintscript name '%s' length < instdir length %zd", + cmd->filename, instdirlen); + return cmd->filename + instdirlen; } diff --git a/src/trigproc.c b/src/trigproc.c index b9681a273..9c73d4ca6 100644 --- a/src/trigproc.c +++ b/src/trigproc.c @@ -25,7 +25,6 @@ #include <sys/stat.h> -#include <assert.h> #include <fcntl.h> #include <stdlib.h> @@ -335,8 +334,11 @@ check_trigger_cycle(struct pkginfo *processing_now) debug(dbg_triggers, "check_triggers_cycle pnow=%s giveup=%s", pkg_name(processing_now, pnaw_always), pkg_name(giveup, pnaw_always)); - assert(giveup->status == PKG_STAT_TRIGGERSAWAITED || - giveup->status == PKG_STAT_TRIGGERSPENDING); + if (giveup->status != PKG_STAT_TRIGGERSAWAITED && + giveup->status != PKG_STAT_TRIGGERSPENDING) + internerr("package %s in non-trigger state %s", + pkg_name(giveup, pnaw_always), + pkg_status_name(giveup)); pkg_set_status(giveup, PKG_STAT_HALFCONFIGURED); modstatdb_note(giveup); print_error_perpackage(_("triggers looping, abandoned"), @@ -367,8 +369,11 @@ trigproc(struct pkginfo *pkg, enum trigproc_type type) if (pkg->trigpend_head) { enum dep_check ok; - assert(pkg->status == PKG_STAT_TRIGGERSPENDING || - pkg->status == PKG_STAT_TRIGGERSAWAITED); + if (pkg->status != PKG_STAT_TRIGGERSPENDING && + pkg->status != PKG_STAT_TRIGGERSAWAITED) + internerr("package %s in non-trigger state %s", + pkg_name(pkg, pnaw_always), + pkg_status_name(pkg)); if (dependtry > 1) { gaveup = check_trigger_cycle(pkg); diff --git a/src/unpack.c b/src/unpack.c index ed2427206..f43c01e45 100644 --- a/src/unpack.c +++ b/src/unpack.c @@ -28,7 +28,6 @@ #include <sys/stat.h> #include <sys/wait.h> -#include <assert.h> #include <errno.h> #include <string.h> #include <time.h> @@ -859,8 +858,12 @@ pkg_disappear_others(struct pkginfo *pkg) debug(dbg_veryverbose, "process_archive checking disappearance %s", pkg_name(otherpkg, pnaw_always)); - assert(otherpkg->clientdata->istobe == PKG_ISTOBE_NORMAL || - otherpkg->clientdata->istobe == PKG_ISTOBE_DECONFIGURE); + + if (otherpkg->clientdata->istobe != PKG_ISTOBE_NORMAL && + otherpkg->clientdata->istobe != PKG_ISTOBE_DECONFIGURE) + internerr("disappearing package %s is not to be normal or deconfigure, " + "is to be %d", + pkg_name(otherpkg, pnaw_always), otherpkg->clientdata->istobe); for (cfile = otherpkg->clientdata->files; cfile && strcmp(cfile->namenode->name, "/.") == 0; @@ -1226,7 +1229,10 @@ void process_archive(const char *filename) { oldversionstatus= pkg->status; - assert(oldversionstatus <= PKG_STAT_INSTALLED); + if (oldversionstatus > PKG_STAT_INSTALLED) + internerr("package %s state %d is out-of-bounds", + pkg_name(pkg, pnaw_always), oldversionstatus); + debug(dbg_general,"process_archive oldversionstatus=%s", statusstrings[oldversionstatus]); @@ -1516,7 +1522,9 @@ void process_archive(const char *filename) { if (otherpkg->installed.arch != pkg->installed.arch) continue; - assert(otherpkg->status == PKG_STAT_NOTINSTALLED); + if (otherpkg->status != PKG_STAT_NOTINSTALLED) + internerr("other package %s instance in state %s instead of not-installed", + pkg_name(otherpkg, pnaw_always), pkg_status_name(otherpkg)); pkg_blank(otherpkg); } |