mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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.
This commit is contained in:
parent
b53d104ae3
commit
bff7bc6cb7
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
|
|
||||||
static void exit_nicely(PGconn *conn);
|
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,
|
static bool process_result(PGconn *conn, PGresult *res, int results,
|
||||||
int numsent);
|
int numsent);
|
||||||
|
|
||||||
@ -916,7 +918,7 @@ test_prepared(PGconn *conn)
|
|||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
pg_fatal("expected COMMAND_OK, got %s", PQresStatus(PQresultStatus(res)));
|
pg_fatal("expected COMMAND_OK, got %s", PQresStatus(PQresultStatus(res)));
|
||||||
if (PQnfields(res) != lengthof(expected_oids))
|
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));
|
lengthof(expected_oids), PQnfields(res));
|
||||||
for (int i = 0; i < PQnfields(res); i++)
|
for (int i = 0; i < PQnfields(res); i++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user