From 8467b0c7d0a57e08e188377642dd1c8e641f42d6 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Wed, 3 Dec 2025 13:25:24 +0000
Subject: [PATCH v1] Use func(void) for functions with no parameters

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.

This commit replaces empty parameter lists with explicit void to enable proper
type checking and eliminate possible undefined behavior if the function is called
with parameters. This also prevents real bugs (API misuse for example).

Note: C23 made func() and func(void) equivalent.
---
 src/backend/access/common/heaptuple.c                 | 2 +-
 src/backend/access/index/genam.c                      | 2 +-
 src/backend/replication/logical/applyparallelworker.c | 2 +-
 src/backend/replication/logical/sequencesync.c        | 2 +-
 src/backend/replication/logical/slotsync.c            | 2 +-
 src/backend/replication/logical/tablesync.c           | 2 +-
 src/backend/replication/logical/worker.c              | 2 +-
 src/backend/utils/adt/uuid.c                          | 4 ++--
 8 files changed, 9 insertions(+), 9 deletions(-)
   8.7% src/backend/access/common/
   9.8% src/backend/access/index/
  50.0% src/backend/replication/logical/
  31.4% src/backend/utils/adt/

diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 74a52d87067..1967b047020 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -123,7 +123,7 @@ missing_match(const void *key1, const void *key2, Size keysize)
 }
 
 static void
-init_missing_cache()
+init_missing_cache(void)
 {
 	HASHCTL		hash_ctl;
 
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
index 0cb27af1310..c96917085c2 100644
--- a/src/backend/access/index/genam.c
+++ b/src/backend/access/index/genam.c
@@ -488,7 +488,7 @@ systable_beginscan(Relation heapRelation,
  * is declared.
  */
 static inline void
-HandleConcurrentAbort()
+HandleConcurrentAbort(void)
 {
 	if (TransactionIdIsValid(CheckXidAlive) &&
 		!TransactionIdIsInProgress(CheckXidAlive) &&
diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c
index baa68c1ab6c..a4eb3962cb1 100644
--- a/src/backend/replication/logical/applyparallelworker.c
+++ b/src/backend/replication/logical/applyparallelworker.c
@@ -640,7 +640,7 @@ pa_detach_all_error_mq(void)
  * Check if there are any pending spooled messages.
  */
 static bool
-pa_has_spooled_message_pending()
+pa_has_spooled_message_pending(void)
 {
 	PartialFileSetState fileset_state;
 
diff --git a/src/backend/replication/logical/sequencesync.c b/src/backend/replication/logical/sequencesync.c
index e093e65e540..019e5ec6a7d 100644
--- a/src/backend/replication/logical/sequencesync.c
+++ b/src/backend/replication/logical/sequencesync.c
@@ -711,7 +711,7 @@ LogicalRepSyncSequences(void)
  * resource error and are not repeatable.
  */
 static void
-start_sequence_sync()
+start_sequence_sync(void)
 {
 	Assert(am_sequencesync_worker());
 
diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c
index 53c7d629239..31d7cb3ca77 100644
--- a/src/backend/replication/logical/slotsync.c
+++ b/src/backend/replication/logical/slotsync.c
@@ -1410,7 +1410,7 @@ check_and_set_sync_info(pid_t worker_pid)
  * Reset syncing flag.
  */
 static void
-reset_syncing_flag()
+reset_syncing_flag(void)
 {
 	SpinLockAcquire(&SlotSyncCtx->mutex);
 	SlotSyncCtx->syncing = false;
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index fa8e3bf969a..6bb0cbeedad 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -1551,7 +1551,7 @@ start_table_sync(XLogRecPtr *origin_startpos, char **slotname)
  * and starts streaming to catchup with apply worker.
  */
 static void
-run_tablesync_worker()
+run_tablesync_worker(void)
 {
 	char		originname[NAMEDATALEN];
 	XLogRecPtr	origin_startpos = InvalidXLogRecPtr;
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 93970c6af29..e22f1a1edef 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -5561,7 +5561,7 @@ set_stream_options(WalRcvStreamOptions *options,
  * Cleanup the memory for subxacts and reset the related variables.
  */
 static inline void
-cleanup_subxact_info()
+cleanup_subxact_info(void)
 {
 	if (subxact_data.subxacts)
 		pfree(subxact_data.subxacts);
diff --git a/src/backend/utils/adt/uuid.c b/src/backend/utils/adt/uuid.c
index e5f27ff892b..5df35d7cacb 100644
--- a/src/backend/utils/adt/uuid.c
+++ b/src/backend/utils/adt/uuid.c
@@ -71,7 +71,7 @@ static int	uuid_fast_cmp(Datum x, Datum y, SortSupport ssup);
 static bool uuid_abbrev_abort(int memtupcount, SortSupport ssup);
 static Datum uuid_abbrev_convert(Datum original, SortSupport ssup);
 static inline void uuid_set_version(pg_uuid_t *uuid, unsigned char version);
-static inline int64 get_real_time_ns_ascending();
+static inline int64 get_real_time_ns_ascending(void);
 static pg_uuid_t *generate_uuidv7(uint64 unix_ts_ms, uint32 sub_ms);
 
 Datum
@@ -545,7 +545,7 @@ gen_random_uuid(PG_FUNCTION_ARGS)
  * than the previous returned timestamp (on this backend).
  */
 static inline int64
-get_real_time_ns_ascending()
+get_real_time_ns_ascending(void)
 {
 	static int64 previous_ns = 0;
 	int64		ns;
-- 
2.34.1

