Use func(void) for functions with no parameters
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2025-12-03T14:51:25Z
Lists: pgsql-hackers
Attachments
Hi hackers, In C standards till C17, func() means "unspecified parameters" while func(void) means "no parameters". The former disables compile time type checking and was marked obsolescent in C99 ([1]). This patch replaces empty parameter lists with explicit void to enable proper type checking and eliminate possible undefined behavior (see [1]) if the function is called with parameters. This also prevents real bugs (API misuse for example). Remarks: - C23 ([2]) made func() and func(void) equivalent and would produce an error if an argument is passed. - The patch has been generated with the help of a coccinelle script [3]. It does modify 8 functions and did not touch the few ones in .c "test" files (libpq_testclient.c for example). [1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf [2]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf [3]: https://github.com/bdrouvot/coccinelle_on_pg/blob/main/misc/use_func_void.cocci Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Enable -Wstrict-prototypes and -Wold-style-definition by default
- 29bf4ee7496c 19 (unreleased) landed
-
Use "foo(void)" for definitions of functions with no parameters.
- 9b05e2ec08a3 19 (unreleased) landed