summaryrefslogtreecommitdiff
path: root/src/trigproc.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2017-03-15 13:33:09 +0100
committerGuillem Jover <guillem@debian.org>2018-03-26 15:30:18 +0200
commit9f7e58acdf28043bce2dfaf24ba27bb878418658 (patch)
treef5aabf9b868cb158cf380af4ab065fc2cdcf402b /src/trigproc.c
parent9622251478262d26ab6e01aa865417370a533069 (diff)
downloaddpkg-9f7e58acdf28043bce2dfaf24ba27bb878418658.tar.gz
Use internerr() or BUG() instead of assert()
The problem with assert() is that it does not print the contents of the variables. It also can be disabled on NDEBUG. But we always want these consistency checks no matter what, and they are not performance sensitive anyway. Enable -Wno-nonnull-compare so that we can keep doing run-time non-NULL checks in functions, instead of just compile-time checks.
Diffstat (limited to 'src/trigproc.c')
-rw-r--r--src/trigproc.c15
1 files changed, 10 insertions, 5 deletions
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);