]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
string_utils: ensure that errno is set on return
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 1 Apr 2021 08:56:52 +0000 (10:56 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 1 Apr 2021 09:08:11 +0000 (11:08 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/string_utils.c

index e5321d826d55d5a241f19cc20278cd3406156071..a5bc7cced1923ddff4281759ed31005b6fa674a4 100644 (file)
@@ -657,7 +657,7 @@ int lxc_safe_int64_residual(const char *numstr, int64_t *converted, int base, ch
        errno = 0;
        u = strtoll(numstr, &remaining, base);
        if (errno == ERANGE && u == INT64_MAX)
-               return -ERANGE;
+               return ret_errno(ERANGE);
 
        if (remaining == numstr)
                return -EINVAL;
@@ -670,11 +670,11 @@ int lxc_safe_int64_residual(const char *numstr, int64_t *converted, int base, ch
 
                len = strlen(remaining);
                if (len >= residual_len)
-                       return -EINVAL;
+                       return ret_errno(EINVAL);
 
                memcpy(residual, remaining, len);
        } else if (*remaining != '\0') {
-               return -EINVAL;
+               return ret_errno(EINVAL);
        }
 
 out: