aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-09-15 17:17:53 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-09-15 17:17:53 -0400
commitcf2c7a736e4939ff0d6cf2acd29b17eea3bca7c2 (patch)
treef776d138d102dbfed014ed4f3770581a48a46e6f /src
parent3a06a79cd137d294bc82d931769d778c8c9aec91 (diff)
downloadpostgresql-cf2c7a736e4939ff0d6cf2acd29b17eea3bca7c2.tar.gz
postgresql-cf2c7a736e4939ff0d6cf2acd29b17eea3bca7c2.zip
Detect format-string mistakes in the libpq_pipeline test module.
I happened to notice that libpq_pipeline's private implementation of pg_fatal lacked any pg_attribute_printf decoration. Indeed, adding that turned up a mistake! We'd likely never have noticed because the error exits in this code are unlikely to get hit, but still, it's a bug. We're so used to having the compiler check this stuff for us that a printf-like function without pg_attribute_printf is a land mine. I wonder if there is a way to detect such omissions. Back-patch to v14 where this code came in.
Diffstat (limited to 'src')
-rw-r--r--src/test/modules/libpq_pipeline/libpq_pipeline.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/test/modules/libpq_pipeline/libpq_pipeline.c b/src/test/modules/libpq_pipeline/libpq_pipeline.c
index 0407c4a8c00..6600ebb0c29 100644
--- a/src/test/modules/libpq_pipeline/libpq_pipeline.c
+++ b/src/test/modules/libpq_pipeline/libpq_pipeline.c
@@ -26,6 +26,8 @@
static void exit_nicely(PGconn *conn);
+static void pg_attribute_noreturn() pg_fatal_impl(int line, const char *fmt,...)
+ pg_attribute_printf(2, 3);
static bool process_result(PGconn *conn, PGresult *res, int results,
int numsent);
@@ -914,7 +916,7 @@ test_prepared(PGconn *conn)
if (PQresultStatus(res) != PGRES_COMMAND_OK)
pg_fatal("expected COMMAND_OK, got %s", PQresStatus(PQresultStatus(res)));
if (PQnfields(res) != lengthof(expected_oids))
- pg_fatal("expected %d columns, got %d",
+ pg_fatal("expected %zd columns, got %d",
lengthof(expected_oids), PQnfields(res));
for (int i = 0; i < PQnfields(res); i++)
{