commit 4e9967da803e7d23a719bc37e0acfc04abb5e192
parent 21c4993cc3c70a205d960306418a8e68492df21a
Author: Louis Burda <quent.burda@gmail.com>
Date: Mon, 27 Mar 2023 21:13:38 +0200
Compile with -O2 on non-debug builds
Diffstat:
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
@@ -2,11 +2,14 @@ PREFIX ?= /usr/local
INCLDIR ?= /include
LIBDIR ?= /lib
-CFLAGS = -Wno-prototype -Wunused-function -Wunused-variable -Wconversion
CFLAGS += -I include -I lib/liballoc/include
+CFLAGS += -Wunused-function -Wunused-variable -Wno-prototype
+CFLAGS += -Wconversion -Wsign-compare -Werror
ifeq "$(DEBUG)" "1"
-CFLAGS += -g
+CFLAGS += -Og -g
+else
+CFLAGS += -O2
endif
ifeq "$(ASSERT_ARGS)" "1"
diff --git a/include/hmap.h b/include/hmap.h
@@ -32,7 +32,7 @@ typedef uint32_t (*hmap_hash_func)(struct hmap_key key);
typedef bool (*hmap_keycmp_func)(struct hmap_key k1, struct hmap_key k2);
enum {
- HMAP_OK,
+ HMAP_OK = 0,
HMAP_KEY_EXISTS,
HMAP_KEY_MISSING,
};
diff --git a/src/hmap.c b/src/hmap.c
@@ -45,7 +45,7 @@ hmap_alloc(struct hmap **map, size_t size, hmap_hash_func hasher,
{
int rc;
- LIBHMAP_ABORT_ON_ARGS(!allocator)
+ LIBHMAP_ABORT_ON_ARGS(!allocator);
rc = allocator->alloc((void **)map, sizeof(struct hmap));
if (rc) return -rc;
diff --git a/src/test.c b/src/test.c
@@ -17,7 +17,7 @@ main(int argc, const char **argv)
{
struct hmap hmap;
struct hmap_iter iter;
- void *key;
+ char *arg;
int i, rc;
rc = hmap_init(&hmap, 10, hmap_str_hash,
@@ -25,8 +25,8 @@ main(int argc, const char **argv)
if (rc) LIBHMAP_ERR(rc);
for (i = 1; i < argc; i++) {
- key = strdup(argv[i]);
- rc = hmap_add(&hmap, (struct hmap_key) {.p = key},
+ arg = strdup(argv[i]);
+ rc = hmap_add(&hmap, (struct hmap_key) {.p = arg},
(struct hmap_val) {.i = i});
if (rc) LIBHMAP_ERR(rc);
}
@@ -37,6 +37,6 @@ main(int argc, const char **argv)
}
for (HMAP_ITER(&hmap, &iter))
- free(iter.link->key.p);
+ free(iter.link->key._p);
hmap_deinit(&hmap);
}