summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2018-03-25 16:36:29 +0200
committerGuillem Jover <guillem@debian.org>2018-03-26 15:30:18 +0200
commit4a6e59ebda3148aeffcab80db57bf114436232b0 (patch)
treea8fa96f6fe6853e3c4afc16d8d9b3c2fd55b31da /utils
parent88d4da0a6c8ae18ddce08cee27c16abb72f8c454 (diff)
downloaddpkg-4a6e59ebda3148aeffcab80db57bf114436232b0.tar.gz
s-s-d: Add support for new bug() function and BUG() macro
These will take care of reporting internal errors or programming bugs in the code.
Diffstat (limited to 'utils')
-rw-r--r--utils/start-stop-daemon.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 813575044..44ae328a5 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -302,6 +302,25 @@ fatal(const char *format, ...)
exit(2);
}
+#define BUG(...) bug(__FILE__, __LINE__, __func__, __VA_ARGS__)
+
+static void DPKG_ATTR_NORET DPKG_ATTR_PRINTF(4)
+bug(const char *file, int line, const char *func, const char *format, ...)
+{
+ va_list arglist;
+
+ fprintf(stderr, "%s:%s:%d:%s: internal error: ",
+ progname, file, line, func);
+ va_start(arglist, format);
+ vfprintf(stderr, format, arglist);
+ va_end(arglist);
+
+ if (action == ACTION_STATUS)
+ exit(STATUS_UNKNOWN);
+ else
+ exit(3);
+}
+
static void *
xmalloc(int size)
{