Re: Using the %m printf format more
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@postgresql.org
Date: 2024-03-11T11:19:16Z
Lists: pgsql-hackers
Attachments
Michael Paquier <michael@paquier.xyz> writes: > On Wed, Mar 06, 2024 at 07:11:19PM +0000, Dagfinn Ilmari Mannsåker wrote: > >> 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() > > I am not really following your argument with pg_regress.c and > fprintf(). d6c55de1f99a should make that possible even in the case of > emit_tap_output_v(), no? The problem isn't that emit_tap_output_v() doesn't support %m, which it does, but that it potentially calls fprintf() to output TAP protocol elements such as "\n" and "# " before it calls vprintf(…, fmt, …), and those calls might clobber errno. An option is to make it save errno at the start and restore it before the vprintf() calls, as in the second attached patch. >> and other potentially errno-modifying functions before >> evaluating the format string. > > Sure. On closer look, fprintf() is actually the only errno-clobbering function it calls, I was just hedging my bets in that statement. - ilmari
Commits
-
pg_regress: Save errno in emit_tap_output_v() and switch to %m
- 85230a247c74 17.0 landed
-
Use printf's %m format instead of strerror(errno) in more places
- 2c8118ee5d98 17.0 landed
-
Add --copy-file-range option to pg_upgrade.
- d93627bcbe50 17.0 cited