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

Commitb5c838e

Browse files
committed
Clean up ecpg's use of mmerror(): const-ify the format argument, add an
__attribute__() marker so that gcc can validate the format string againstthe actual arguments, get rid of overcomplicated and unsafe usage inbase_yyerror().
1 parenta734979 commitb5c838e

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

‎src/interfaces/ecpg/preproc/ecpg.header

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.5 2009/01/23 12:43:32 petere Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.6 2009/06/03 20:24:51 tgl Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -56,7 +56,7 @@ struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};
5656
* Handle parsing errors and warnings
5757
*/
5858
void
59-
mmerror(int error_code, enum errortype type, char *error, ...)
59+
mmerror(int error_code, enum errortype type,constchar *error, ...)
6060
{
6161
va_list ap;
6262

‎src/interfaces/ecpg/preproc/ecpg.trailer

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.7 2009/04/06 08:42:53 heikki Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.8 2009/06/03 20:24:51 tgl Exp $ */
22

33
statements: /*EMPTY*/
44
| statements statement
@@ -1985,13 +1985,10 @@ ecpg_into: INTO into_list{ $$ = EMPTY; }
19851985

19861986
%%
19871987

1988-
void base_yyerror(const char *error)
1988+
void base_yyerror(const char *error)
19891989
{
1990-
char buf[1024];
1991-
1992-
snprintf(buf,sizeof buf, _("%s at or near \"%s\""), error, token_start ? token_start : yytext);
1993-
buf[sizeof(buf)-1]=0;
1994-
mmerror(PARSE_ERROR, ET_ERROR, buf);
1990+
mmerror(PARSE_ERROR, ET_ERROR, "%s at or near \"%s\"",
1991+
error, token_start ? token_start : yytext);
19951992
}
19961993

19971994
void parser_init(void)

‎src/interfaces/ecpg/preproc/extern.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.71 2008/05/20 23:17:32 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.72 2009/06/03 20:24:51 tgl Exp $ */
22

33
#ifndef_ECPG_PREPROC_EXTERN_H
44
#define_ECPG_PREPROC_EXTERN_H
@@ -74,7 +74,9 @@ extern intbase_yylex(void);
7474
externvoidbase_yyerror(constchar*);
7575
externvoid*mm_alloc(size_t),*mm_realloc(void*,size_t);
7676
externchar*mm_strdup(constchar*);
77-
externvoidmmerror(int,enumerrortype,char*,...);
77+
externvoidmmerror(int,enumerrortype,constchar*, ...)
78+
/* This extension allows gcc to check the format string */
79+
__attribute__((format(printf,3,4)));
7880
externvoidoutput_get_descr_header(char*);
7981
externvoidoutput_get_descr(char*,char*);
8082
externvoidoutput_set_descr_header(char*);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp