mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-27 15:16:03 +00:00
Fix compile error with GCC 8 in makefsdata
lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:56: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename); /home/dziegel/lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:3: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 256 snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename); Reduce subdir string length by 3 bytes to make the warning go away. The whole file path including directory AND filename is limited to MAX_PATH_LEN - so it is reasonable to reserve 3 bytes less for directory - the filename won't fit anyway in the remaining 3 bytes.
This commit is contained in:
parent
ee1bab3411
commit
30b2d07362
@ -132,7 +132,7 @@ static int file_can_be_compressed(const char* filename);
|
||||
/* 5 bytes per char + 3 bytes per line */
|
||||
static char file_buffer_c[COPY_BUFSIZE * 5 + ((COPY_BUFSIZE / HEX_BYTES_PER_LINE) * 3)];
|
||||
|
||||
char curSubdir[MAX_PATH_LEN];
|
||||
char curSubdir[MAX_PATH_LEN-3];
|
||||
char lastFileVar[MAX_PATH_LEN];
|
||||
char hdr_buf[4096];
|
||||
|
||||
@ -926,9 +926,9 @@ int process_file(FILE *data_file, FILE *struct_file, const char *filename)
|
||||
int flags_printed;
|
||||
|
||||
/* create qualified name (@todo: prepend slash or not?) */
|
||||
sprintf(qualifiedName, "%s/%s", curSubdir, filename);
|
||||
snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);
|
||||
/* create C variable name */
|
||||
strcpy(varname, qualifiedName);
|
||||
strncpy(varname, qualifiedName, sizeof(varname));
|
||||
/* convert slashes & dots to underscores */
|
||||
fix_filename_for_c(varname, MAX_PATH_LEN);
|
||||
register_filename(varname);
|
||||
|
Loading…
Reference in New Issue
Block a user