git » libfiu » commit e66c047

preload/posix: Specify void in empty function declarations

author HX Lin
2025-08-19 09:58:53 UTC
committer Alberto Bertogli
2025-09-06 21:27:24 UTC
parent d323d8d4a8de3c78b63ba079ea4e0674c91b7681

preload/posix: Specify void in empty function declarations

Some functions (like `fork()`) have no parameters. In such cases, the code
generator would produce an empty PARAMST.

When those are compiled with `-Wstrict-prototypes`, that will result in
warnings on the `_fiu_init_##NAME()` functions.

To fix this, we explicitly set `void` on those cases, as per modern C
standards.

https://github.com/albertito/libfiu/pull/11

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Edited commit message, added comment.

preload/posix/generate +4 -0

diff --git a/preload/posix/generate b/preload/posix/generate
index c13dbe6..a78eef9 100755
--- a/preload/posix/generate
+++ b/preload/posix/generate
@@ -109,6 +109,10 @@ class Function:
 
 		# extract params names and types
 		paramst = ', '.join([i[0] for i in self.params_info])
+		if not paramst:
+			# Explicitly use (void) when there are no parameters, to conform
+			# to modern C standards.
+			paramst = 'void'
 		paramsn = ', '.join([i[1] for i in self.params_info])
 
 		f.write('mkwrap_top(%s, %s, (%s), (%s), (%s), (%s))\n' % \