git » libfiu » commit 0147613

Specify `void` in empty function declarations

author HX Lin
2025-08-07 10:30:05 UTC
committer Alberto Bertogli
2025-08-13 21:52:55 UTC
parent ad7e719abca02b872620354b1e8fdd5f46847e2c

Specify `void` in empty function declarations

`clang -Wall` includes `-Wstrict-prototypes`, which complains about
declarations with empty parameters, like `void func()`.

Modern C standards say those should be explicitly marked with `void`,
e.g. `void func(void)`.

This patch updates all such declarations so they comply to new
standards, and as a result, building with clang (or
`-Wstrict-prototypes`) no longer shows warnings.

https://github.com/albertito/libfiu/pull/5
https://github.com/albertito/libfiu/pull/6

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Edited commit message, squashed library and test commits.

libfiu/backtrace.c +2 -2
libfiu/fiu.c +2 -2
libfiu/hash.c +1 -1
libfiu/hash.h +1 -1
libfiu/internal.h +1 -1
tests/test-enable_stack.c +2 -2
tests/test-enable_stack_by_name.c +2 -2
tests/test-parallel-wildcard.c +1 -1
tests/test-parallel.c +1 -1

diff --git a/libfiu/backtrace.c b/libfiu/backtrace.c
index a20fb89..2a6adef 100644
--- a/libfiu/backtrace.c
+++ b/libfiu/backtrace.c
@@ -84,14 +84,14 @@ void *get_func_addr(const char *func_name)
 /* Ugly but useful conversion from function pointer to void *.
  * This is not guaranteed by the standard, but has to work on all platforms
  * where we support backtrace(), because that function assumes it so. */
-static void *fp_to_voidp(void (*funcp)())
+static void *fp_to_voidp(void (*funcp)(void))
 {
 	unsigned char **p;
 	p = (unsigned char **)&funcp;
 	return *p;
 }
 
-int backtrace_works(void (*caller)())
+int backtrace_works(void (*caller)(void))
 {
 	/* We remember the result so we don't have to compute it over an over
 	 * again, we know it doesn't change. */
diff --git a/libfiu/fiu.c b/libfiu/fiu.c
index 1ab8b17..3cf710b 100644
--- a/libfiu/fiu.c
+++ b/libfiu/fiu.c
@@ -455,7 +455,7 @@ int fiu_enable_stack(const char *name, int failnum, void *failinfo,
 	if (func_pos_in_stack != -1)
 		return -1;
 
-	if (backtrace_works((void (*)())fiu_enable_stack) == 0)
+	if (backtrace_works((void (*)(void))fiu_enable_stack) == 0)
 		return -1;
 
 	// We need either get_func_end() or get_func_start() to work, see
@@ -483,7 +483,7 @@ int fiu_enable_stack_by_name(const char *name, int failnum, void *failinfo,
 	/* We need to check this here instead of relying on the test within
 	 * fiu_enable_stack() in case it is inlined; that would fail the check
 	 * because fiu_enable_stack() would not be in the stack. */
-	if (backtrace_works((void (*)())fiu_enable_stack_by_name) == 0)
+	if (backtrace_works((void (*)(void))fiu_enable_stack_by_name) == 0)
 		return -1;
 
 	fp = get_func_addr(func_name);
diff --git a/libfiu/hash.c b/libfiu/hash.c
index dd2e4c7..8cfcef9 100644
--- a/libfiu/hash.c
+++ b/libfiu/hash.c
@@ -344,7 +344,7 @@ struct cache {
 	pthread_rwlock_t lock;
 };
 
-struct cache *cache_create()
+struct cache *cache_create(void)
 {
 	struct cache *c;
 
diff --git a/libfiu/hash.h b/libfiu/hash.h
index 93163a1..3369a5b 100644
--- a/libfiu/hash.h
+++ b/libfiu/hash.h
@@ -21,7 +21,7 @@ bool hash_del(hash_t *h, const char *key);
 
 typedef struct cache cache_t;
 
-cache_t *cache_create();
+cache_t *cache_create(void);
 bool cache_resize(struct cache *c, size_t new_size);
 void cache_free(cache_t *c);
 
diff --git a/libfiu/internal.h b/libfiu/internal.h
index f872117..aa9b2cc 100644
--- a/libfiu/internal.h
+++ b/libfiu/internal.h
@@ -24,6 +24,6 @@ void *get_func_addr(const char *func_name);
 
 /* Do the above backtrace-related functions work?
  * Takes a pointer to the caller so it can verify it's on the stack. */
-int backtrace_works(void (*caller)());
+int backtrace_works(void (*caller)(void));
 
 #endif
diff --git a/tests/test-enable_stack.c b/tests/test-enable_stack.c
index b68dce1..dfbcd92 100644
--- a/tests/test-enable_stack.c
+++ b/tests/test-enable_stack.c
@@ -6,7 +6,7 @@
 #include <fiu-control.h>
 #include <fiu.h>
 
-int __attribute__((noinline)) func1()
+int __attribute__((noinline)) func1(void)
 {
 	/*
 	int nptrs;
@@ -18,7 +18,7 @@ int __attribute__((noinline)) func1()
 	return fiu_fail("fp-1") != 0;
 }
 
-int __attribute__((noinline)) func2()
+int __attribute__((noinline)) func2(void)
 {
 	return func1();
 }
diff --git a/tests/test-enable_stack_by_name.c b/tests/test-enable_stack_by_name.c
index c6cc051..c628006 100644
--- a/tests/test-enable_stack_by_name.c
+++ b/tests/test-enable_stack_by_name.c
@@ -6,7 +6,7 @@
 #include <fiu-control.h>
 #include <fiu.h>
 
-int __attribute__((noinline)) func1()
+int __attribute__((noinline)) func1(void)
 {
 	/*
 	int nptrs;
@@ -18,7 +18,7 @@ int __attribute__((noinline)) func1()
 	return fiu_fail("fp-1") != 0;
 }
 
-int __attribute__((noinline)) func2()
+int __attribute__((noinline)) func2(void)
 {
 	return func1();
 }
diff --git a/tests/test-parallel-wildcard.c b/tests/test-parallel-wildcard.c
index 57cfb0b..3c552b7 100644
--- a/tests/test-parallel-wildcard.c
+++ b/tests/test-parallel-wildcard.c
@@ -150,7 +150,7 @@ void *enabler(void *unused)
 	return NULL;
 }
 
-void disable_all()
+void disable_all(void)
 {
 	int high;
 
diff --git a/tests/test-parallel.c b/tests/test-parallel.c
index a0e3c8b..a450a7d 100644
--- a/tests/test-parallel.c
+++ b/tests/test-parallel.c
@@ -123,7 +123,7 @@ void *enabler(void *unused)
 	return NULL;
 }
 
-void disable_all()
+void disable_all(void)
 {
 	int i = 0;