From eb4b11dda7c6099b93c49554169cdc622e942f48 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 2 Jul 2024 06:31:52 +0200 Subject: [PATCH 1/3] Formatting --- ringbuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ringbuf.h b/ringbuf.h index efffe50..4e3cbb8 100644 --- a/ringbuf.h +++ b/ringbuf.h @@ -26,7 +26,7 @@ struct RingBuf { } __attribute__((packed)); /* - * Considerations: One hot encoding for the enum values + * Considerations: One hot encoding for the enum values * (8 bit each with -fshort-enums) */ From ea100383d7bba52e6c23c2657bfa424b7d6a0f33 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 2 Jul 2024 06:32:22 +0200 Subject: [PATCH 2/3] Typedef for free function signature --- ringbuf.c | 4 ++-- ringbuf.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ringbuf.c b/ringbuf.c index 23adb94..9ea1a6d 100644 --- a/ringbuf.c +++ b/ringbuf.c @@ -40,9 +40,9 @@ rb_init(struct RingBuf *rb, rb_size_t capacity, ALLOC_T malloc_fn, } void -rb_destroy(struct RingBuf *rb, void(free)()) +rb_destroy(struct RingBuf *rb, FREE_T free_fn) { - free(rb->buffer); + free_fn(rb->buffer); } void diff --git a/ringbuf.h b/ringbuf.h index 4e3cbb8..6d6d01f 100644 --- a/ringbuf.h +++ b/ringbuf.h @@ -12,6 +12,9 @@ typedef void *(*ALLOC_T)(rb_size_t); /** Signature of memcpy */ typedef void *(*MEMCPY_T)(void *, const void *, rb_size_t); +/** Signature of free */ +typedef void (*FREE_T)(void *); + /** * @brief Ring buffer, also known as circular buffer. */ From 6022bdee9245200bcad638298a4f14483bce7fa4 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 2 Jul 2024 06:33:00 +0200 Subject: [PATCH 3/3] tidy makefile target to run clang-tidy --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 760129d..6b1324e 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,9 @@ asm: $(ASMS) $(OBJECTS) wc -l $(ASMS) size $(OBJECTS) +tidy: + @clang-tidy $(C_SOURCES) -- $(CFLAGS) + format: clang-format -i $(C_SOURCES) $(C_HEADERS)