aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-13 11:38:10 +0100
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-13 11:38:10 +0100
commit104864b6ea7a1cf8b3371dc8426757b560b97638 (patch)
treed9e3c16f7a95dba5458cce9c8a9e84de7e29dd10
parent353474b87153ee8bb0bcfef77576a3f012172bd3 (diff)
downloadmapper.lv2-104864b6ea7a1cf8b3371dc8426757b560b97638.zip
mapper.lv2-104864b6ea7a1cf8b3371dc8426757b560b97638.tar.gz
mapper.lv2-104864b6ea7a1cf8b3371dc8426757b560b97638.tar.bz2
mapper.lv2-104864b6ea7a1cf8b3371dc8426757b560b97638.tar.xz
make it pass pedantic build.
-rw-r--r--mapper.lv2/mapper.h6
-rw-r--r--test/Makefile9
-rw-r--r--test/mapper_test.c3
3 files changed, 13 insertions, 5 deletions
diff --git a/mapper.lv2/mapper.h b/mapper.lv2/mapper.h
index 7fa74d9..104917e 100644
--- a/mapper.lv2/mapper.h
+++ b/mapper.lv2/mapper.h
@@ -82,7 +82,7 @@ struct _mapper_t {
LV2_URID_Map map;
LV2_URID_Unmap unmap;
- mapper_item_t items [0];
+ mapper_item_t items [];
};
/*
@@ -124,7 +124,7 @@ _mapper_murmur3_32(const void *data, size_t nbytes)
const int nblocks = nbytes / 4;
const uint32_t *blocks = (const uint32_t *)(data);
- const uint8_t *tail = (const uint8_t *)(data + (nblocks * 4));
+ const uint8_t *tail = (const uint8_t *)data + (nblocks * 4);
uint32_t h = 0;
@@ -147,8 +147,10 @@ _mapper_murmur3_32(const void *data, size_t nbytes)
{
case 3:
k ^= tail[2] << 16;
+ __attribute__((fallthrough));
case 2:
k ^= tail[1] << 8;
+ __attribute__((fallthrough));
case 1:
k ^= tail[0];
k *= c1;
diff --git a/test/Makefile b/test/Makefile
index b8c5642..b722b73 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,12 +1,14 @@
CC ?= clang
+C_FLAGS ?= -I../ -Wall -Wextra -Wpedantic $(shell pkg-config --cflags lv2)
+LD_FLAGS ?= -lpthread
all: mapper_assert mapper_speed
mapper_assert: mapper_test.c ../mapper.lv2/mapper.h
- $(CC) -std=gnu11 -g -o $@ $< -I../ $(shell pkg-config --cflags lv2) -lpthread
+ $(CC) -std=c11 -g -o $@ $< $(C_FLAGS) $(LD_FLAGS)
mapper_speed: mapper_test.c ../mapper.lv2/mapper.h
- $(CC) -std=gnu11 -O3 -o $@ $< -I../ $(shell pkg-config --cflags lv2) -lpthread
+ $(CC) -std=c11 -O3 -o $@ $< $(C_FLAGS) $(LD_FLAGS)
test_assert: mapper_assert
./$< 1 0
@@ -25,3 +27,6 @@ test_speed: mapper_speed
./$< 32 1
test: test_assert test_speed
+
+clean:
+ rm -f mapper_assert mapper_speed
diff --git a/test/mapper_test.c b/test/mapper_test.c
index e605b07..212a5dc 100644
--- a/test/mapper_test.c
+++ b/test/mapper_test.c
@@ -41,7 +41,7 @@ struct _rtmem_slot_t {
struct _rtmem_t {
atomic_uint nalloc; // counts number of allocations
atomic_uint nfree; // counts number of frees
- rtmem_slot_t slots [0]; // contains slots as multiple of MAX_ITEMS
+ rtmem_slot_t slots []; // contains slots as multiple of MAX_ITEMS
};
// dummy non-rt memory structure
@@ -79,6 +79,7 @@ static char *
_rtmem_alloc(void *data, size_t size)
{
rtmem_t *rtmem = data;
+ (void)size;
// dummily just take the next slot according to allocation counter
const uint32_t nalloc = atomic_fetch_add_explicit(&rtmem->nalloc, 1, memory_order_relaxed);