From 879e5fabc60b054f14fdd83a764ba4f47814d2a6 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Wed, 7 May 2025 13:18:04 +0100 Subject: [PATCH] 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 --- shared/util.c | 2 -- 1 file changed, 2 deletions(-) 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; -- 2.47.2