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

Commitc02d5b7

Browse files
committed
Use a macro variable PG_PRINTF_ATTRIBUTE for the style used for checking printf type functions.
The style is set to "printf" for backwards compatibility everywhere excepton Windows, where it is set to "gnu_printf", which eliminates hundreds offalse error messages from modern versions of gcc arising from %m and %ll{d,u}formats.
1 parent39850c7 commitc02d5b7

File tree

16 files changed

+56
-41
lines changed

16 files changed

+56
-41
lines changed

‎src/backend/utils/adt/format_type.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static char *printTypmod(const char *typname, int32 typmod, Oid typmodout);
3333
staticchar*
3434
psnprintf(size_tlen,constchar*fmt,...)
3535
/* This lets gcc check the format string for consistency. */
36-
__attribute__((format(printf,2,3)));
36+
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
3737

3838

3939
/*

‎src/bin/pg_ctl/pg_ctl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void
115115
write_stderr(constchar*fmt,...)
116116
/* This extension allows gcc to check the format string for consistency with
117117
the supplied arguments. */
118-
__attribute__((format(printf,1,2)));
118+
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
119119
staticvoid*pg_malloc(size_tsize);
120120
staticchar*xstrdup(constchar*s);
121121
staticvoiddo_advice(void);

‎src/bin/pg_dump/pg_backup.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ typedef struct _restoreOptions
152152

153153
externvoid
154154
exit_horribly(Archive*AH,constchar*modulename,constchar*fmt,...)
155-
__attribute__((format(printf,3,4)));
155+
__attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
156156

157157

158158
/* Lets the archive know we have a DB connection to shutdown if it dies */
@@ -207,7 +207,7 @@ extern intarchputs(const char *s, Archive *AH);
207207
externint
208208
archprintf(Archive*AH,constchar*fmt,...)
209209
/* This extension allows gcc to check the format string */
210-
__attribute__((format(printf,2,3)));
210+
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
211211

212212
#defineappendStringLiteralAH(buf,str,AH) \
213213
appendStringLiteral(buf, str, (AH)->encoding, (AH)->std_strings)

‎src/bin/pg_dump/pg_backup_archiver.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ typedef struct _tocEntry
328328
/* Used everywhere */
329329
externconstchar*progname;
330330

331-
externvoiddie_horribly(ArchiveHandle*AH,constchar*modulename,constchar*fmt,...) __attribute__((format(printf,3,4)));
332-
externvoidwarn_or_die_horribly(ArchiveHandle*AH,constchar*modulename,constchar*fmt,...) __attribute__((format(printf,3,4)));
333-
externvoidwrite_msg(constchar*modulename,constchar*fmt,...) __attribute__((format(printf,2,3)));
331+
externvoiddie_horribly(ArchiveHandle*AH,constchar*modulename,constchar*fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
332+
externvoidwarn_or_die_horribly(ArchiveHandle*AH,constchar*modulename,constchar*fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
333+
externvoidwrite_msg(constchar*modulename,constchar*fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
334334

335335
externvoidWriteTOC(ArchiveHandle*AH);
336336
externvoidReadTOC(ArchiveHandle*AH);
@@ -378,8 +378,8 @@ extern intReconnectToServer(ArchiveHandle *AH, const char *dbname, const char *
378378
externvoidDropBlobIfExists(ArchiveHandle*AH,Oidoid);
379379

380380
intahwrite(constvoid*ptr,size_tsize,size_tnmemb,ArchiveHandle*AH);
381-
intahprintf(ArchiveHandle*AH,constchar*fmt,...) __attribute__((format(printf,2,3)));
381+
intahprintf(ArchiveHandle*AH,constchar*fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
382382

383-
voidahlog(ArchiveHandle*AH,intlevel,constchar*fmt,...) __attribute__((format(printf,3,4)));
383+
voidahlog(ArchiveHandle*AH,intlevel,constchar*fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
384384

385385
#endif

‎src/bin/psql/common.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern bool setQFout(const char *fname);
3636
externvoid
3737
psql_error(constchar*fmt,...)
3838
/* This lets gcc check the format string for consistency. */
39-
__attribute__((format(printf,1,2)));
39+
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
4040

4141
externvoidNoticeProcessor(void*arg,constchar*message);
4242

‎src/bin/psql/large_obj.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
staticvoid
1616
print_lo_result(constchar*fmt,...)
17-
__attribute__((format(printf,1,2)));
17+
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
1818

1919
staticvoid
2020
print_lo_result(constchar*fmt,...)

‎src/include/c.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ typedef NameData *Name;
773773
externint
774774
snprintf(char*str,size_tcount,constchar*fmt,...)
775775
/* This extension allows gcc to check the format string */
776-
__attribute__((format(printf,3,4)));
776+
__attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
777777
#endif
778778

779779
#if !HAVE_DECL_VSNPRINTF

‎src/include/lib/stringinfo.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extern void resetStringInfo(StringInfo str);
9595
externvoid
9696
appendStringInfo(StringInfostr,constchar*fmt,...)
9797
/* This extension allows gcc to check the format string */
98-
__attribute__((format(printf,2,3)));
98+
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
9999

100100
/*------------------------
101101
* appendStringInfoVA

‎src/include/pg_config_manual.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@
154154
*/
155155
#defineMAX_RANDOM_VALUE (0x7FFFFFFF)
156156

157+
/*
158+
* Set the format style used by gcc to check printf type functions. We really
159+
* want the "gnu_printf" style set, which includes what glibc uses, such
160+
* as %m for error strings and %lld for 64 bit long longs. But not all gcc
161+
* compilers are known to support it, so we just use "printf" which all
162+
* gcc versions alive are known to support, except on Windows where
163+
* using "gnu_printf" style makes a dramatic difference. Maybe someday
164+
* we'll have a configure test for this, if we ever discover use of more
165+
* variants to be necessary.
166+
*/
167+
#ifdefWIN32
168+
#definePG_PRINTF_ATTRIBUTE gnu_printf
169+
#else
170+
#definePG_PRINTF_ATTRIBUTE printf
171+
#endif
157172

158173
/*
159174
*------------------------------------------------------------------------

‎src/include/port.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,20 @@ extern intpg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
197197
externint
198198
pg_snprintf(char*str,size_tcount,constchar*fmt,...)
199199
/* This extension allows gcc to check the format string */
200-
__attribute__((format(printf,3,4)));
200+
__attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
201201
externint
202202
pg_sprintf(char*str,constchar*fmt,...)
203203
/* This extension allows gcc to check the format string */
204-
__attribute__((format(printf,2,3)));
204+
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
205205
externintpg_vfprintf(FILE*stream,constchar*fmt,va_listargs);
206206
externint
207207
pg_fprintf(FILE*stream,constchar*fmt,...)
208208
/* This extension allows gcc to check the format string */
209-
__attribute__((format(printf,2,3)));
209+
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
210210
externint
211211
pg_printf(constchar*fmt,...)
212212
/* This extension allows gcc to check the format string */
213-
__attribute__((format(printf,1,2)));
213+
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
214214

215215
/*
216216
*The GCC-specific code below prevents the __attribute__(... 'printf')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp