Skip to content

Commit

Permalink
sys/sysctl.h: Fix wrong assertion with multiple access flags
Browse files Browse the repository at this point in the history
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:		10a1e98 iflib: mark isc_driver_version as constant
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45531
  • Loading branch information
gmshake authored and bsdjhb committed Sep 4, 2024
2 parents 0eec993 + 23f4131 commit 35f0c0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sys/sys/sysctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,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 | \
Expand Down

0 comments on commit 35f0c0e

Please sign in to comment.