From 51207b9076f43351ad88c68be4febd03993a683c Mon Sep 17 00:00:00 2001 From: Agustin Chiappe Berrini Date: Tue, 22 Aug 2017 18:44:32 -0400 Subject: [PATCH] fix compilation of fetch_cb on gcc 7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original message: ``` fetch_cb.c:80:29: error: ‘h’ directive output may be truncated writing 1 byte into a region of size between 0 and 14 [-Werror=format-truncation=] snprintf(str, sizeof str, "%02ldh%02ldm", ^~~~~~~~~~~~~~ fetch_cb.c:80:29: note: directive argument in the range [0, 59] fetch_cb.c:80:3: note: ‘snprintf’ output between 7 and 21 bytes into a destination of size 16 snprintf(str, sizeof str, "%02ldh%02ldm", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ eta / 3600, (eta % 3600) / 60); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fetch_cb.c:83:30: error: ‘%02ld’ directive output may be truncated writing between 2 and 19 bytes into a region of size 16 [-Werror=format-truncation=] snprintf(str, sizeof str, "%02ldm%02lds", ^~~~~ fetch_cb.c:83:29: note: directive argument in the range [-153722867280912930, 60] snprintf(str, sizeof str, "%02ldm%02lds", ^~~~~~~~~~~~~~ fetch_cb.c:83:29: note: directive argument in the range [-59, 59] fetch_cb.c:83:3: note: ‘snprintf’ output between 7 and 25 bytes into a destination of size 16 snprintf(str, sizeof str, "%02ldm%02lds", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ eta / 60, eta % 60); ~~~~~~~~~~~~~~~~~~~ fetch_cb.c:80:29: error: ‘h’ directive output may be truncated writing 1 byte into a region of size between 0 and 14 [-Werror=format-truncation=] snprintf(str, sizeof str, "%02ldh%02ldm", ^~~~~~~~~~~~~~ fetch_cb.c:80:29: note: directive argument in the range [0, 59] fetch_cb.c:80:3: note: ‘snprintf’ output between 7 and 21 bytes into a destination of size 16 snprintf(str, sizeof str, "%02ldh%02ldm", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ eta / 3600, (eta % 3600) / 60); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fetch_cb.c:83:30: error: ‘%02ld’ directive output may be truncated writing between 2 and 19 bytes into a region of size 16 [-Werror=format-truncation=] snprintf(str, sizeof str, "%02ldm%02lds", ^~~~~ fetch_cb.c:83:29: note: directive argument in the range [-153722867280912930, 60] snprintf(str, sizeof str, "%02ldm%02lds", ^~~~~~~~~~~~~~ fetch_cb.c:83:29: note: directive argument in the range [-59, 59] fetch_cb.c:83:3: note: ‘snprintf’ output between 7 and 25 bytes into a destination of size 16 snprintf(str, sizeof str, "%02ldm%02lds", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ eta / 60, eta % 60); ~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ``` --- bin/xbps-install/fetch_cb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xbps-install/fetch_cb.c b/bin/xbps-install/fetch_cb.c index a0f158d3..8d10ac17 100644 --- a/bin/xbps-install/fetch_cb.c +++ b/bin/xbps-install/fetch_cb.c @@ -65,7 +65,7 @@ static const char * stat_eta(const struct xbps_fetch_cb_data *xfpd, void *cbdata) { struct xferstat *xfer = cbdata; - static char str[16]; + static char str[25]; long elapsed, eta; off_t received, expected;