diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/fsutil.c | 4 | ||||
-rw-r--r-- | src/shared/include/assert.h | 3 | ||||
-rw-r--r-- | src/shared/path.c | 4 |
3 files changed, 5 insertions, 6 deletions
diff --git a/src/shared/fsutil.c b/src/shared/fsutil.c index a03ed0c..ffdcc43 100644 --- a/src/shared/fsutil.c +++ b/src/shared/fsutil.c @@ -1,9 +1,7 @@ +#include <assert.h> #include <camellia/fsutil.h> #include <limits.h> -// TODO shared assert -#define assert(...) {} - void fs_normslice(long *restrict offset, size_t *restrict length, size_t max, bool expand) { assert(max <= (size_t)LONG_MAX); diff --git a/src/shared/include/assert.h b/src/shared/include/assert.h new file mode 100644 index 0000000..7adf297 --- /dev/null +++ b/src/shared/include/assert.h @@ -0,0 +1,3 @@ +#pragma once +#define assert(stmt) do { if (!(stmt)) __badassert(__func__, __FILE__, __LINE__); } while (0) +_Noreturn void __badassert(const char *func, const char *file, int line); diff --git a/src/shared/path.c b/src/shared/path.c index 9d2eda3..175796f 100644 --- a/src/shared/path.c +++ b/src/shared/path.c @@ -1,10 +1,8 @@ +#include <assert.h> #include <camellia/path.h> #include <shared/mem.h> #include <stdbool.h> -// TODO shared assert -#define assert(...) - int path_simplify(const char *in, char *out, size_t len) { if (len == 0) return -1; // empty paths are invalid if (in[0] != '/') return -1; // so are relative paths |