mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 20:46:50 +03:00
Utils: Filename: Squash warning: -Wformat-truncation=
We need to check the snprintf return value, or GCC7 whinges: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
This commit is contained in:
parent
fdaad39a57
commit
7bd1fb50c6
@ -272,15 +272,19 @@ bool filename_flush_directory(const char *folder, int depth)
|
|||||||
parent = opendir(folder);
|
parent = opendir(folder);
|
||||||
|
|
||||||
while ((entry = readdir(parent))) {
|
while ((entry = readdir(parent))) {
|
||||||
struct stat statbuf;
|
int written;
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
/* Ignore '.' and '..' */
|
/* Ignore '.' and '..' */
|
||||||
if (strcmp(entry->d_name, ".") == 0 ||
|
if (strcmp(entry->d_name, ".") == 0 ||
|
||||||
strcmp(entry->d_name, "..") == 0)
|
strcmp(entry->d_name, "..") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(child, sizeof(child), "%s/%s", folder, entry->d_name);
|
written = snprintf(child, sizeof(child), "%s/%s",
|
||||||
child[sizeof(child) - 1] = '\0';
|
folder, entry->d_name);
|
||||||
|
if (written == sizeof(child)) {
|
||||||
|
child[sizeof(child) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if (stat(child, &statbuf) == -1) {
|
if (stat(child, &statbuf) == -1) {
|
||||||
NSLOG(netsurf, INFO, "Unable to stat %s: %s", child,
|
NSLOG(netsurf, INFO, "Unable to stat %s: %s", child,
|
||||||
@ -383,16 +387,21 @@ bool filename_delete_recursive(char *folder)
|
|||||||
parent = opendir(folder);
|
parent = opendir(folder);
|
||||||
|
|
||||||
while ((entry = readdir(parent))) {
|
while ((entry = readdir(parent))) {
|
||||||
|
int written;
|
||||||
|
|
||||||
/* Ignore '.' and '..' */
|
/* Ignore '.' and '..' */
|
||||||
if (strcmp(entry->d_name, ".") == 0 ||
|
if (strcmp(entry->d_name, ".") == 0 ||
|
||||||
strcmp(entry->d_name, "..") == 0)
|
strcmp(entry->d_name, "..") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(child, sizeof(child), "%s/%s", folder, entry->d_name);
|
written = snprintf(child, sizeof(child), "%s/%s",
|
||||||
child[sizeof(child) - 1] = '\0';
|
folder, entry->d_name);
|
||||||
|
if (written == sizeof(child)) {
|
||||||
|
child[sizeof(child) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if (stat(child, &statbuf) == -1) {
|
if (stat(child, &statbuf) == -1) {
|
||||||
NSLOG(netsurf, INFO, "Unable to stat %s: %s", child,
|
NSLOG(netsurf, INFO, "Unable to stat %s: %s", child,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user