Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jun 2024 04:49:26 GMT
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 9cd77bd9c68b - stable/14 - sys/sysctl.h: Fix wrong assertion with multiple access flags
Message-ID:  <202406110449.45B4nQJ6092244@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=9cd77bd9c68bda6134c6672e9a923869b7923343

commit 9cd77bd9c68bda6134c6672e9a923869b7923343
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-06-08 03:21:11 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-06-11 04:48:59 +0000

    sys/sysctl.h: Fix wrong assertion with multiple access flags
    
    With multiple flags passed in, e.g., CTLFLAG_RD | CTLFLAG_CAPRD, due to
    the precedence rules, this will result in false positive assertion. Fix
    that by surrounding the replacement lists with parentheses.
    
    Reviewed by:    imp, erj
    Fixes:          10a1e981d411 iflib: mark isc_driver_version as constant
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D45531
    
    (cherry picked from commit 23f4131ad685debef98566351cb9f0e0a5903903)
---
 sys/sys/sysctl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index bc7a2bc601a1..76cbae25f4e5 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -395,14 +395,14 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
 #define	SYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr)	\
 	SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING | CTLFLAG_MPSAFE | (access),\
 	    __DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \
-	CTASSERT(!(access & CTLFLAG_WR));				\
+	CTASSERT(!((access) & CTLFLAG_WR));				\
 	CTASSERT(((access) & CTLTYPE) == 0 ||				\
 	    ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING)
 
 #define	SYSCTL_ADD_CONST_STRING(ctx, parent, nbr, name, access, arg, descr) \
 ({									\
 	char *__arg = __DECONST(char *, arg);				\
-	CTASSERT(!(access & CTLFLAG_WR));				\
+	CTASSERT(!((access) & CTLFLAG_WR));				\
 	CTASSERT(((access) & CTLTYPE) == 0 ||				\
 	    ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING);	\
 	sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING | 	\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202406110449.45B4nQJ6092244>