]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared: don't reset errno in read_str_{u,}long()
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 7 May 2025 12:18:04 +0000 (13:18 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 20 May 2025 02:51:43 +0000 (21:51 -0500)
Currently we reset errno prior to calling strto{u,}l(). This is not
needed, since a) we don't check errno to see if the function was
successful and b) we explicitly propagate the error code by returning it
directly to the caller.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
shared/util.c

index fcb223508d7bde3de0e0ac946dd46d62654c2d96..e6916f84ad8743506f2d2d6f2b27f6f2288941a0 100644 (file)
@@ -274,7 +274,6 @@ int read_str_long(int fd, long *value, int base)
        err = read_str_safe(fd, buf, sizeof(buf));
        if (err < 0)
                return err;
-       errno = 0;
        v = strtol(buf, &end, base);
        if (end == buf || !isspace(*end))
                return -EINVAL;
@@ -293,7 +292,6 @@ int read_str_ulong(int fd, unsigned long *value, int base)
        err = read_str_safe(fd, buf, sizeof(buf));
        if (err < 0)
                return err;
-       errno = 0;
        v = strtoul(buf, &end, base);
        if (end == buf || !isspace(*end))
                return -EINVAL;