Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit46b5e7c

Browse files
committed
Revert "Distinguish printf-like functions that support %m from those that don't."
This reverts commit3a60c8f. Buildfarmresults show that that caused a whole bunch of new warnings on platformswhere gcc believes the local printf to be non-POSIX-compliant. Thisproblem outweighs the hypothetical-anyway possibility of getting warningsfor misuse of %m. We could use gnu_printf archetype when we've substitutedsrc/port/snprintf.c, but that brings us right back to the problem of notgetting warnings for %m.A possible answer is to attack it in the other direction by insistingthat %m support be included in printf's feature set, but that will takemore investigation. In the meantime, revert the previous change, andupdate the comment for PGAC_C_PRINTF_ARCHETYPE to more fully explainwhat's going on.Discussion:https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
1 parentd11eae0 commit46b5e7c

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

‎config/c-compiler.m4

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ fi])# PGAC_C_SIGNED
1919

2020
# PGAC_C_PRINTF_ARCHETYPE
2121
# -----------------------
22-
# Set the format archetype used by gcc to check elog/ereport functions.
23-
# This should accept %m, whether or not the platform's printf does.
24-
# We use "gnu_printf" if possible, which does that, although in some cases
25-
# it might do more than we could wish.
22+
# Select the format archetype to be used by gcc to check printf-type functions.
23+
# We prefer "gnu_printf", which matches the features glibc supports, notably
24+
# %m, 'z' and 'll' width modifiers ('ll' only matters if int64 requires it),
25+
# and argument order control if we're doing --enable-nls. On platforms where
26+
# the native printf doesn't have 'z'/'ll' or arg control, we replace it with
27+
# src/port/snprintf.c which does, so that the only potential mismatch here is
28+
# whether or not %m is supported. We need that for elog/ereport, so we live
29+
# with the fact that erroneous use of %m in plain printf calls won't be
30+
# detected. (It appears that many versions of gcc/clang wouldn't report it
31+
# even if told to check according to plain printf archetype, anyway.)
2632
AC_DEFUN([PGAC_PRINTF_ARCHETYPE],
27-
[AC_CACHE_CHECK([for printf format archetype for %m],pgac_cv_printf_archetype,
33+
[AC_CACHE_CHECK([for printf format archetype],pgac_cv_printf_archetype,
2834
[ac_save_c_werror_flag=$ac_c_werror_flag
2935
ac_c_werror_flag=yes
3036
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
@@ -34,8 +40,8 @@ __attribute__((format(gnu_printf, 2, 3)));], [])],
3440
[pgac_cv_printf_archetype=gnu_printf],
3541
[pgac_cv_printf_archetype=printf])
3642
ac_c_werror_flag=$ac_save_c_werror_flag])
37-
AC_DEFINE_UNQUOTED([PG_PRINTF_ATTRIBUTE_M],[$pgac_cv_printf_archetype],
38-
[Defineas a format archetype that accepts %m, if available, else printf.])
43+
AC_DEFINE_UNQUOTED([PG_PRINTF_ATTRIBUTE],[$pgac_cv_printf_archetype],
44+
[Defineto gnu_printf if compiler supports it, else printf.])
3945
])# PGAC_PRINTF_ARCHETYPE
4046

4147

‎configure

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13362,8 +13362,8 @@ _ACEOF
1336213362
;;
1336313363
esac
1336413364

13365-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf format archetype for %m" >&5
13366-
$as_echo_n "checking for printf format archetype for %m... " >&6; }
13365+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf format archetype" >&5
13366+
$as_echo_n "checking for printf format archetype... " >&6; }
1336713367
if ${pgac_cv_printf_archetype+:} false; then :
1336813368
$as_echo_n "(cached) " >&6
1336913369
else
@@ -13394,7 +13394,7 @@ fi
1339413394
$as_echo "$pgac_cv_printf_archetype" >&6; }
1339513395

1339613396
cat >>confdefs.h <<_ACEOF
13397-
#definePG_PRINTF_ATTRIBUTE_M $pgac_cv_printf_archetype
13397+
#definePG_PRINTF_ATTRIBUTE $pgac_cv_printf_archetype
1339813398
_ACEOF
1339913399

1340013400

‎src/include/c.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,10 @@
126126
/* GCC and XLC support format attributes */
127127
#if defined(__GNUC__)|| defined(__IBMC__)
128128
#definepg_attribute_format_arg(a) __attribute__((format_arg(a)))
129-
/* Use for functions wrapping stdio's printf, which often doesn't take %m: */
130-
#definepg_attribute_printf(f,a) __attribute__((format(printf, f, a)))
131-
/* Use for elog/ereport, which implement %m for themselves: */
132-
#definepg_attribute_printf_m(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE_M, f, a)))
129+
#definepg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
133130
#else
134131
#definepg_attribute_format_arg(a)
135132
#definepg_attribute_printf(f,a)
136-
#definepg_attribute_printf_m(f,a)
137133
#endif
138134

139135
/* GCC, Sunpro and XLC support aligned, packed and noreturn */

‎src/include/pg_config.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@
809809
/* PostgreSQL major version as a string */
810810
#undef PG_MAJORVERSION
811811

812-
/* Defineas a format archetype that accepts %m, if available, else printf. */
813-
#undefPG_PRINTF_ATTRIBUTE_M
812+
/* Defineto gnu_printf if compiler supports it, else printf. */
813+
#undefPG_PRINTF_ATTRIBUTE
814814

815815
/* PostgreSQL version as a string */
816816
#undef PG_VERSION

‎src/include/utils/elog.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,25 @@ extern interrcode(int sqlerrcode);
152152
externinterrcode_for_file_access(void);
153153
externinterrcode_for_socket_access(void);
154154

155-
externinterrmsg(constchar*fmt,...)pg_attribute_printf_m(1,2);
156-
externinterrmsg_internal(constchar*fmt,...)pg_attribute_printf_m(1,2);
155+
externinterrmsg(constchar*fmt,...)pg_attribute_printf(1,2);
156+
externinterrmsg_internal(constchar*fmt,...)pg_attribute_printf(1,2);
157157

158158
externinterrmsg_plural(constchar*fmt_singular,constchar*fmt_plural,
159-
unsigned longn,...)pg_attribute_printf_m(1,4)pg_attribute_printf_m(2,4);
159+
unsigned longn,...)pg_attribute_printf(1,4)pg_attribute_printf(2,4);
160160

161-
externinterrdetail(constchar*fmt,...)pg_attribute_printf_m(1,2);
162-
externinterrdetail_internal(constchar*fmt,...)pg_attribute_printf_m(1,2);
161+
externinterrdetail(constchar*fmt,...)pg_attribute_printf(1,2);
162+
externinterrdetail_internal(constchar*fmt,...)pg_attribute_printf(1,2);
163163

164-
externinterrdetail_log(constchar*fmt,...)pg_attribute_printf_m(1,2);
164+
externinterrdetail_log(constchar*fmt,...)pg_attribute_printf(1,2);
165165

166166
externinterrdetail_log_plural(constchar*fmt_singular,
167167
constchar*fmt_plural,
168-
unsigned longn,...)pg_attribute_printf_m(1,4)pg_attribute_printf_m(2,4);
168+
unsigned longn,...)pg_attribute_printf(1,4)pg_attribute_printf(2,4);
169169

170170
externinterrdetail_plural(constchar*fmt_singular,constchar*fmt_plural,
171-
unsigned longn,...)pg_attribute_printf_m(1,4)pg_attribute_printf_m(2,4);
171+
unsigned longn,...)pg_attribute_printf(1,4)pg_attribute_printf(2,4);
172172

173-
externinterrhint(constchar*fmt,...)pg_attribute_printf_m(1,2);
173+
externinterrhint(constchar*fmt,...)pg_attribute_printf(1,2);
174174

175175
/*
176176
* errcontext() is typically called in error context callback functions, not
@@ -184,7 +184,7 @@ extern interrhint(const char *fmt,...) pg_attribute_printf_m(1, 2);
184184

185185
externintset_errcontext_domain(constchar*domain);
186186

187-
externinterrcontext_msg(constchar*fmt,...)pg_attribute_printf_m(1,2);
187+
externinterrcontext_msg(constchar*fmt,...)pg_attribute_printf(1,2);
188188

189189
externinterrhidestmt(boolhide_stmt);
190190
externinterrhidecontext(boolhide_ctx);
@@ -243,13 +243,13 @@ extern intgetinternalerrposition(void);
243243
#endif/* HAVE__VA_ARGS */
244244

245245
externvoidelog_start(constchar*filename,intlineno,constchar*funcname);
246-
externvoidelog_finish(intelevel,constchar*fmt,...)pg_attribute_printf_m(2,3);
246+
externvoidelog_finish(intelevel,constchar*fmt,...)pg_attribute_printf(2,3);
247247

248248

249249
/* Support for constructing error strings separately from ereport() calls */
250250

251251
externvoidpre_format_elog_string(interrnumber,constchar*domain);
252-
externchar*format_elog_string(constchar*fmt,...)pg_attribute_printf_m(1,2);
252+
externchar*format_elog_string(constchar*fmt,...)pg_attribute_printf(1,2);
253253

254254

255255
/* Support for attaching context information to error reports */
@@ -428,9 +428,9 @@ extern void set_syslog_parameters(const char *ident, int facility);
428428
#endif
429429

430430
/*
431-
* Write errors to stderr (or bycomparable means when stderr is not
432-
* available).Used before ereport/elog can be used safely (memory context,
433-
* GUC load etc). Note that this does *not* accept "%m".
431+
* Write errors to stderr (or byequal means when stderr is
432+
*notavailable). Used before ereport/elog can be used
433+
*safely (memory context,GUC load etc)
434434
*/
435435
externvoidwrite_stderr(constchar*fmt,...)pg_attribute_printf(1,2);
436436

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp