Using the %m printf format more

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Using the %m printf format more
Date: 2024-03-06 19:11:19
Message-ID: 87sf13jhuw.fsf@wibble.ilmari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

I just noticed that commit d93627bc added a bunch of pg_fatal() calls
using %s and strerror(errno), which could be written more concisely as
%m. I'm assuming this was done because the surrounding code also uses
this pattern, and hadn't been changed to use %m when support for that
was added to snprintf.c to avoid backporting hazards. However, that
support was in v12, which is now the oldest still-supported back branch,
so we can safely make that change.

The attached patch does so everywhere appropriate. One place where it's
not appropriate is the TAP-emitting functions in pg_regress, since those
call fprintf() and other potentially errno-modifying functions before
evaluating the format string.

- ilmari

Attachment Content-Type Size
0001-Use-m-printf-format-instead-of-strerror-errno-where-.patch text/x-diff 42.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message a.imamov 2024-03-06 19:12:46 Re: Potential issue in ecpg-informix decimal converting functions
Previous Message Stephen Frost 2024-03-06 19:09:59 Re: Proposal to add page headers to SLRU pages