From nobody Fri Jan 2 07:40:49 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4djFx257wdz6MTnT for ; Fri, 02 Jan 2026 07:40:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4djFwx4RWRz49Ns for ; Fri, 02 Jan 2026 07:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767339649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6CIouuqymknNOBEbc1g49C9d95fTVENgH+1NEE4m6po=; b=pqS282NpV5N5N/92kben3ARwhB9tA16Oyh3e5bpl54q7BMkE8FSzZTrjCXd5YkxhqfDVEY mAeA4FB4OMxytH6sXa19WElMDE3xdWn1ZwFENrQHy2YUmaZ+w1q2QHzhM7lCWaW0AyxNwx Ug+JFzBtTY23Zfhrb4qwZnOep3Vp5CciLk8xDc3lAhOvTcfWNTZ0LqLIKy/sKKc0GXtqhS GmW0AZVw/pVCUbYTY0plc4LpKo4dcfhrWYNK+xHpoMk+/4UV8l7Jh7U6wQCiVIyGyxLEhZ rPwWKhAElkDHM8PMrmQd1GmPruLHkAm8l+RiwxCOJzbkmP0NNd63PgTPQST1hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767339649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6CIouuqymknNOBEbc1g49C9d95fTVENgH+1NEE4m6po=; b=U+RBv6uqVQa2USXJ7UdK0uwrlj5RKitu6mOyGNMYRRyRYNEI8I83NUpnyULy3qMbqy6u8F lrRfL2CB62vlvOEkaqrCv5J2pG84i5cuTmhT535mXCNn72cTmOITJL4seGRFjCchZjf1AG sC1uMeb0vALQuloRYMN4GrnMiXP5ZYxxypO7BVfrGmOpAQkHzjmwEhapKDGLdte4miRTio jBwdekUgEH16eFYIqyfNXfqx0MkPamDKqU9J54MZ0YA3aRBAvl5BIgrYs1xXmU4o2ZdXv9 6vFeHRqJRm4ta/lOYcQKmnSJUM9tpmE3ddN4ntbGryMp9xdW1Gt+10LtJ8Egqw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767339649; a=rsa-sha256; cv=none; b=O/DMubopqBo/xqD8hzPp+9pqRnUGFfJinS+3/rPFz4poG5LIfH+TZPpizoUjRdHln4aLRv Ttx7ywJHrGe0xOqwiorQ7109g9HLfHj5+E1t/YsgkHQdpGjxyv+amaOA8YhBuGWdMmAlPW zC9VBlmF1jO5W6KxmpBQul4gkqq7Q/J90xNOnyEc+8UI9+hYR5ptjrCcTkatKVZF49xNIg aNpE1bVJwunvEZF+NoQT0EgwTR0vJuHvJ19V+RdC2UzkIygEmV+vcVjzFUWqaKXSysHPID HM2OS8UOKe58AgdgogNb8QA9DFy51XBJTMfHp+wm+OZiB2jW85G7FNdtrGm0Pg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4djFwx40RQz17HV for ; Fri, 02 Jan 2026 07:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3e120 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 02 Jan 2026 07:40:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 3542d60fb804 - main - linuxkpi: Don't clobber result on failure List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3542d60fb8042474f66fbf2d779ed8c5a80d0f78 Auto-Submitted: auto-generated Date: Fri, 02 Jan 2026 07:40:49 +0000 Message-Id: <69577681.3e120.15bea2a2@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=3542d60fb8042474f66fbf2d779ed8c5a80d0f78 commit 3542d60fb8042474f66fbf2d779ed8c5a80d0f78 Author: Dag-Erling Smørgrav AuthorDate: 2026-01-02 07:30:06 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-01-02 07:30:06 +0000 linuxkpi: Don't clobber result on failure In kstrto*(), don't assign to *res until we know the conversion is successful, and address issues that may result in warnings if code that uses is compiled at high warning levels. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: bz, emaste Differential Revision: https://reviews.freebsd.org/D54440 --- sys/compat/linuxkpi/common/include/linux/kstrtox.h | 43 +++++++++++++++------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kstrtox.h b/sys/compat/linuxkpi/common/include/linux/kstrtox.h index 5da99de24197..6a145c409038 100644 --- a/sys/compat/linuxkpi/common/include/linux/kstrtox.h +++ b/sys/compat/linuxkpi/common/include/linux/kstrtox.h @@ -74,14 +74,17 @@ static inline int kstrtoul(const char *cp, unsigned int base, unsigned long *res) { char *end; + unsigned long temp; - *res = strtoul(cp, &end, base); + temp = strtoul(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') end++; if (*cp == 0 || *end != 0) return (-EINVAL); + + *res = temp; return (0); } @@ -89,14 +92,17 @@ static inline int kstrtol(const char *cp, unsigned int base, long *res) { char *end; + long temp; - *res = strtol(cp, &end, base); + temp = strtol(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') end++; if (*cp == 0 || *end != 0) return (-EINVAL); + + *res = temp; return (0); } @@ -106,7 +112,7 @@ kstrtoint(const char *cp, unsigned int base, int *res) char *end; long temp; - *res = temp = strtol(cp, &end, base); + temp = strtol(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') @@ -115,6 +121,8 @@ kstrtoint(const char *cp, unsigned int base, int *res) return (-EINVAL); if (temp != (int)temp) return (-ERANGE); + + *res = (int)temp; return (0); } @@ -124,7 +132,7 @@ kstrtouint(const char *cp, unsigned int base, unsigned int *res) char *end; unsigned long temp; - *res = temp = strtoul(cp, &end, base); + temp = strtoul(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') @@ -133,6 +141,8 @@ kstrtouint(const char *cp, unsigned int base, unsigned int *res) return (-EINVAL); if (temp != (unsigned int)temp) return (-ERANGE); + + *res = (unsigned int)temp; return (0); } @@ -142,7 +152,7 @@ kstrtou8(const char *cp, unsigned int base, uint8_t *res) char *end; unsigned long temp; - *res = temp = strtoul(cp, &end, base); + temp = strtoul(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') @@ -151,6 +161,8 @@ kstrtou8(const char *cp, unsigned int base, uint8_t *res) return (-EINVAL); if (temp != (uint8_t)temp) return (-ERANGE); + + *res = (uint8_t)temp; return (0); } @@ -160,7 +172,7 @@ kstrtou16(const char *cp, unsigned int base, uint16_t *res) char *end; unsigned long temp; - *res = temp = strtoul(cp, &end, base); + temp = strtoul(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') @@ -169,20 +181,20 @@ kstrtou16(const char *cp, unsigned int base, uint16_t *res) return (-EINVAL); if (temp != (uint16_t)temp) return (-ERANGE); + + *res = (uint16_t)temp; return (0); } static inline int kstrtou32(const char *cp, unsigned int base, uint32_t *res) { - return (kstrtouint(cp, base, res)); } static inline int kstrtos32(const char *cp, unsigned int base, int32_t *res) { - return (kstrtoint(cp, base, res)); } @@ -190,14 +202,17 @@ static inline int kstrtos64(const char *cp, unsigned int base, int64_t *res) { char *end; + quad_t temp; - *res = strtoq(cp, &end, base); + temp = strtoq(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') end++; if (*cp == 0 || *end != 0) return (-EINVAL); + + *res = (int64_t)temp; return (0); } @@ -208,17 +223,20 @@ kstrtoll(const char *cp, unsigned int base, long long *res) } static inline int -kstrtou64(const char *cp, unsigned int base, u64 *res) +kstrtou64(const char *cp, unsigned int base, uint64_t *res) { char *end; + u_quad_t temp; - *res = strtouq(cp, &end, base); + temp = strtouq(cp, &end, base); /* skip newline character, if any */ if (*end == '\n') end++; if (*cp == 0 || *end != 0) return (-EINVAL); + + *res = (uint64_t)temp; return (0); } @@ -231,7 +249,7 @@ kstrtoull(const char *cp, unsigned int base, unsigned long long *res) static inline int kstrtobool(const char *s, bool *res) { - int len; + size_t len; if (s == NULL || (len = strlen(s)) == 0 || res == NULL) return (-EINVAL); @@ -302,7 +320,6 @@ static inline int kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *p) { - return (kstrtouint_from_user(s, count, base, p)); }