From: Michael Tremer Date: Mon, 10 Feb 2025 17:38:48 +0000 (+0000) Subject: string: Fix error handling for strftime functions X-Git-Tag: 0.9.30~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c83c23657d85dd07f57c5c7921f05248cb85b50;p=pakfire.git string: Fix error handling for strftime functions Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/string.c b/src/pakfire/string.c index f7508446..31aea956 100644 --- a/src/pakfire/string.c +++ b/src/pakfire/string.c @@ -632,13 +632,14 @@ int __pakfire_format_speed(char* dst, size_t length, double value) { int __pakfire_strftime(char* buffer, const size_t length, const char* format, const time_t t) { - struct tm* tm = gmtime(&t); int r; + struct tm* tm = gmtime(&t); + // Format time r = strftime(buffer, length, format, tm); - if (r == 0) - return 1; + if (r < 0) + return -errno; return 0; } @@ -647,7 +648,7 @@ int __pakfire_strftime_now(char* buffer, size_t length, const char* format) { // Fetch the current time const time_t t = time(NULL); if (t < 0) - return 1; + return -errno; return __pakfire_strftime(buffer, length, format, t); }