commit 998fd4e66fcc49b732b3fac151c0271d4dc17943
parent 07f9ee7bba9ad42e770c91f5db06fe8d73541666
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Sun, 29 Aug 2021 12:17:40 -0700
Simplify bug reporting
Diffstat:
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/aps/aps.c b/aps/aps.c
@@ -28,6 +28,7 @@
#include "aps.h"
#include "arg.h"
#include "asplit.h"
+#include "bug.h"
#include "command.h"
#include "log.h"
#include "queue.h"
@@ -135,7 +136,7 @@ aps_handle(struct aps *aps, int fd)
if (aps->clients[fd].resp->lock && respond(aps, fd))
return 1;
} else {
- BUG("impossible poll event");
+ bug("impossible poll event");
}
return 0;
diff --git a/aps/arg.c b/aps/arg.c
@@ -20,8 +20,6 @@
#include <string.h>
#include <stdlib.h>
-#include "util.h"
-
unsigned int
arglen(char **args)
{
@@ -45,7 +43,6 @@ argdup(char **args, unsigned int len)
return NULL;
for (i = 0; i < len; ++i) {
- ASSERT(args[i] != NULL);
nargs[i] = strdup(args[i]);
if (nargs[i] == NULL)
break;
diff --git a/aps/bug.c b/aps/bug.c
@@ -21,8 +21,15 @@
#include <stdlib.h>
void
-bug(char *file, long line, char *bug)
+bug(char *bug)
{
- fprintf(stderr, "%s:%ld: %s.\n", file, line, bug);
+ fprintf(stderr, "bug: %s\n", bug);
abort();
}
+
+void
+assert(int assertion, char *msg)
+{
+ if (!assertion)
+ bug(msg);
+}
diff --git a/aps/bug.h b/aps/bug.h
@@ -1 +1,2 @@
-void bug(char *, long, char *);
+void bug(char *);
+void assert(int, char *);
diff --git a/aps/command.c b/aps/command.c
@@ -27,6 +27,7 @@
#include "aps.h"
#include "arg.h"
+#include "bug.h"
#include "find.h"
#include "log.h"
#include "queue.h"
@@ -213,7 +214,7 @@ aps_status(struct aps *aps, int s, int argc, char **argv)
status = "complete";
break;
default:
- BUG("impossible player state");
+ bug("impossible player state");
}
if (respadd(aps, s, status))
diff --git a/aps/util.h b/aps/util.h
@@ -1,11 +1,4 @@
-#include "bug.h"
-
#define LEN(X) (sizeof(X) / sizeof(*X))
-
#define MAX(A,B) ((A) > (B) ? (A) : (B))
#define MIN(A,B) ((A) < (B) ? (A) : (B))
-
-#define ASSERT(EXP) ((EXP) ? 0 : BUG(#EXP))
-#define BUG(WHY) (bug(__FILE__, __LINE__, WHY))
-
#define errstr (strerror(errno))