diff options
author | Guillem Jover <guillem@debian.org> | 2017-03-15 13:33:09 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2018-03-26 15:30:18 +0200 |
commit | 9f7e58acdf28043bce2dfaf24ba27bb878418658 (patch) | |
tree | f5aabf9b868cb158cf380af4ab065fc2cdcf402b /dselect/method.cc | |
parent | 9622251478262d26ab6e01aa865417370a533069 (diff) | |
download | dpkg-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 'dselect/method.cc')
-rw-r--r-- | dselect/method.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/dselect/method.cc b/dselect/method.cc index 74ac9842c..76863bc34 100644 --- a/dselect/method.cc +++ b/dselect/method.cc @@ -27,7 +27,6 @@ #include <sys/file.h> #include <sys/wait.h> -#include <assert.h> #include <errno.h> #include <limits.h> #include <string.h> @@ -71,8 +70,10 @@ sthfailed(const char * reasoning) static void cu_unlockmethod(int, void**) { struct flock fl; - assert(methodlockfile); - assert(methlockfd >= 0); + if (methodlockfile == NULL) + internerr("method lock file is NULL"); + if (methlockfd < 0) + internerr("method lock fd is %d < 0", methlockfd); fl.l_type=F_UNLCK; fl.l_whence= SEEK_SET; fl.l_start=fl.l_len=0; if (fcntl(methlockfd,F_SETLK,&fl) == -1) sthfailed(_("cannot unlock access method area")); |