From: Michael Tremer Date: Thu, 8 Jun 2023 17:05:54 +0000 (+0000) Subject: string: Have all functions return negative values on error X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45a3d5aaca4e1d64132d7b4190209bb743efaa68;p=network.git string: Have all functions return negative values on error Signed-off-by: Michael Tremer --- diff --git a/src/networkd/string.h b/src/networkd/string.h index 270ed6be..a36b0238 100644 --- a/src/networkd/string.h +++ b/src/networkd/string.h @@ -37,12 +37,11 @@ static inline int __nw_string_vformat(char* s, const size_t length, // Catch any errors if (required < 0) - return 1; + return required; // Check if the entire string could be written if ((size_t)required >= length) { - errno = ENOMEM; - return 1; + return -ENOMEM; } // Success