Fix GCC warning
source/compiler/sc1.c: In function ‘check_tagmismatch_multiple’: source/compiler/sc1.c:3482:40: warning: ‘"’ directive writing 1 byte into a region of size between 0 and 4094 [-Wformat-overflow=] sprintf(formal_tagnames,"%s\"%s\"",formal_tagnames,(tagsym!=NULL) ? tagsym->name : "-unknown-"); ^~ source/compiler/sc1.c:3482:9: note: ‘sprintf’ output 3 or more bytes (assuming 4097) into a destination of size 4095 sprintf(formal_tagnames,"%s\"%s\"",formal_tagnames,(tagsym!=NULL) ? tagsym->name : "-unknown-"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
parent
ad730d32d8
commit
65d6c98fc2
@ -3469,8 +3469,9 @@ SC_FUNC void check_tagmismatch_multiple(int formaltags[],int numtags,int actualt
|
||||
if (!checktag(formaltags, numtags, actualtag)) {
|
||||
int i;
|
||||
constvalue *tagsym;
|
||||
char formal_tagnames[sLINEMAX]="",actual_tagname[sNAMEMAX+2]="none (\"_\")";
|
||||
char formal_tagnames[sLINEMAX+1]="",actual_tagname[sNAMEMAX+2]="none (\"_\")";
|
||||
int notag_allowed=FALSE,add_comma=FALSE;
|
||||
size_t size;
|
||||
for (i=0; i<numtags; i++) {
|
||||
if(formaltags[i]!=0) {
|
||||
if((i+1)==numtags && add_comma==TRUE && notag_allowed==FALSE)
|
||||
@ -3479,7 +3480,13 @@ SC_FUNC void check_tagmismatch_multiple(int formaltags[],int numtags,int actualt
|
||||
strlcat(formal_tagnames,", ",sizeof(formal_tagnames));
|
||||
add_comma=TRUE;
|
||||
tagsym=find_tag_byval(formaltags[i]);
|
||||
sprintf(formal_tagnames,"%s\"%s\"",formal_tagnames,(tagsym!=NULL) ? tagsym->name : "-unknown-");
|
||||
size=snprintf(formal_tagnames,
|
||||
sizeof(formal_tagnames),
|
||||
"%s\"%s\"",
|
||||
formal_tagnames,
|
||||
(tagsym!=NULL) ? tagsym->name : "-unknown-");
|
||||
if (size>=sizeof(formal_tagnames))
|
||||
break;
|
||||
} else {
|
||||
notag_allowed=TRUE;
|
||||
} /* if */
|
||||
|
Loading…
x
Reference in New Issue
Block a user