From: Shlomi Fish Date: Wed, 15 Dec 2021 19:19:58 +0000 (+0200) Subject: Silence compile-time or run-time warnings. X-Git-Tag: fortune-mod-3.12.0~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e77236c746bd8a402c6441038eb39218c1624a52;p=fortune-mod Silence compile-time or run-time warnings. See: * https://duckduckgo.com/?q=warnings+programming&atb=v140-1&ia=web They are a distraction at best and may indicate other issues. --- diff --git a/fortune-mod/fortune/fortune.c b/fortune-mod/fortune/fortune.c index 32a8ed9..5ce3772 100644 --- a/fortune-mod/fortune/fortune.c +++ b/fortune-mod/fortune/fortune.c @@ -547,6 +547,7 @@ static int open4read(const char *const path) * add_file: * Add a file to the file list. */ +#define GCC_SNPRINTF_MARGIN 10 static int add_file(int percent, const char *file, const char *dir, FILEDESC **head, FILEDESC **tail, FILEDESC *parent) { @@ -562,7 +563,8 @@ static int add_file(int percent, const char *file, const char *dir, } else { - const size_t do_len = (strlen(dir) + strlen(file) + 2); + const size_t do_len = + (strlen(dir) + strlen(file) + (2 + GCC_SNPRINTF_MARGIN)); path = do_malloc(do_len + 1); snprintf(path, do_len, "%s/%s", dir, file); } @@ -1821,7 +1823,7 @@ int main(int argc, char *argv[]) ctype = "ISO-8859-1"; } #endif - const size_t do_len = strlen(ctype) + 7 + 1; + const size_t do_len = strlen(ctype) + (7 + 1 + GCC_SNPRINTF_MARGIN); char *crequest = do_malloc(do_len + 1); snprintf(crequest, do_len, "UTF-8..%s", ctype); recode_scan_request(request, crequest);