]> git.ipfire.org Git - people/ms/network.git/commitdiff
string: Have all functions return negative values on error
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Jun 2023 17:05:54 +0000 (17:05 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Jun 2023 17:05:54 +0000 (17:05 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/string.h

index 270ed6be64de1b80eb2566b406529fb5ef10b7e5..a36b0238e38cf5563b21e6706b64de4dd64d265b 100644 (file)
@@ -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