From 1158f19b4fde1ed81fa4e1e52b096ae8ac579a10 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Mon, 26 Oct 2026 17:01:54 +0800 Subject: [PATCH] Fix two compiler warnings in backend unit tests Compiled with the server's warning flags, two unit test sources warn: ginpostinglist_fakes.c:67: warning: control reaches end of non-void function [-Wreturn-type] dfmgr_test.c:68: warning: function 'errdetail_internal_impl' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format] The pg_fprintf() fake is declared to return int and returned nothing; it returns 0 now. errdetail_internal_impl(), which stands in for errdetail() and errdetail_internal(), now carries their printf attribute, so its callers in dfmgr.c are format-checked as they are against the real functions, and it calls va_end(), which it never did. `make unittest-check` compiles the tests with CFLAGS=-DUNITTEST alone, which is why it does not show these. Assisted-by: Claude Code --- src/backend/access/gin/test/ginpostinglist_fakes.c | 1 + src/backend/utils/fmgr/test/dfmgr_test.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/backend/access/gin/test/ginpostinglist_fakes.c b/src/backend/access/gin/test/ginpostinglist_fakes.c index c703e975dda..3861733bab6 100644 --- a/src/backend/access/gin/test/ginpostinglist_fakes.c +++ b/src/backend/access/gin/test/ginpostinglist_fakes.c @@ -64,4 +64,5 @@ repalloc(void *pointer, Size size) int pg_fprintf(FILE *stream, const char *fmt,...) { + return 0; } diff --git a/src/backend/utils/fmgr/test/dfmgr_test.c b/src/backend/utils/fmgr/test/dfmgr_test.c index 5246e99f496..faaa2c6e7d7 100755 --- a/src/backend/utils/fmgr/test/dfmgr_test.c +++ b/src/backend/utils/fmgr/test/dfmgr_test.c @@ -57,6 +57,8 @@ errmsg_impl(const char *fmt, ...) { } +static void errdetail_internal_impl(const char *fmt, ...) pg_attribute_printf(1, 2); + static void errdetail_internal_impl(const char* fmt, ...) { @@ -66,6 +68,7 @@ errdetail_internal_impl(const char* fmt, ...) va_start(args, fmt); appendStringInfoVA(&buf, fmt, args); + va_end(args); strncpy(lastErrorMsg, buf.data, sizeof(lastErrorMsg) / sizeof(lastErrorMsg[0])); pfree(buf.data);