From: Emil Velikov Date: Wed, 7 May 2025 12:18:04 +0000 (+0100) Subject: shared: don't reset errno in read_str_{u,}long() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=879e5fabc60b054f14fdd83a764ba4f47814d2a6;p=thirdparty%2Fkmod.git shared: don't reset errno in read_str_{u,}long() 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 Link: https://github.com/kmod-project/kmod/pull/346 Signed-off-by: Lucas De Marchi --- diff --git a/shared/util.c b/shared/util.c index fcb22350..e6916f84 100644 --- a/shared/util.c +++ b/shared/util.c @@ -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;