aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-09-12 06:52:31 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-09-20 07:04:10 +0000
commit08862a1a5e14d49c221999a82e2a52690f918a97 (patch)
treecbd05c46d2736ba2ffb904c3dba85c6fecce5281
parente21f1fa8fa98506b1bfb195b02132a84549e89a2 (diff)
downloadsrc-08862a1a5e14d49c221999a82e2a52690f918a97.tar.gz
src-08862a1a5e14d49c221999a82e2a52690f918a97.zip
Fix geom build with clang 17 and KTR enabled
When building a kernel with clang 17 and KTR enabled, such as with the LINT configurations, a -Werror warning is emitted: sys/geom/geom_io.c:145:31: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand] 145 | if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) { | ~~~~~~~~~~~~~~~~~~~~~~~~ ^ sys/geom/geom_io.c:145:31: note: use '&' for a bitwise operation 145 | if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) { | ^~ | & sys/geom/geom_io.c:145:31: note: remove constant to silence this warning Replace the multiple uses of the expression with one macro, and in this macro use "!= 0" to get a logical operand instead of a bitwise one. Reviewed by: jhb MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D41823 (cherry picked from commit 479d224efcbf0115f8cd84314fcc46cbac146a1d)
-rw-r--r--sys/geom/geom_io.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index 84a290dcc970..50db2f0c6639 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -67,6 +67,9 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
+#define KTR_GEOM_ENABLED \
+ ((KTR_COMPILE & KTR_GEOM) != 0 && (ktr_mask & KTR_GEOM) != 0)
+
static int g_io_transient_map_bio(struct bio *bp);
static struct g_bioq g_bio_run_down;
@@ -150,7 +153,7 @@ g_new_bio(void)
bp = uma_zalloc(biozone, M_NOWAIT | M_ZERO);
#ifdef KTR
- if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) {
+ if (KTR_GEOM_ENABLED) {
struct stack st;
CTR1(KTR_GEOM, "g_new_bio(): %p", bp);
@@ -168,7 +171,7 @@ g_alloc_bio(void)
bp = uma_zalloc(biozone, M_WAITOK | M_ZERO);
#ifdef KTR
- if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) {
+ if (KTR_GEOM_ENABLED) {
struct stack st;
CTR1(KTR_GEOM, "g_alloc_bio(): %p", bp);
@@ -183,7 +186,7 @@ void
g_destroy_bio(struct bio *bp)
{
#ifdef KTR
- if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) {
+ if (KTR_GEOM_ENABLED) {
struct stack st;
CTR1(KTR_GEOM, "g_destroy_bio(): %p", bp);
@@ -231,7 +234,7 @@ g_clone_bio(struct bio *bp)
bp->bio_children++;
}
#ifdef KTR
- if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) {
+ if (KTR_GEOM_ENABLED) {
struct stack st;
CTR2(KTR_GEOM, "g_clone_bio(%p): %p", bp, bp2);
@@ -260,7 +263,7 @@ g_duplicate_bio(struct bio *bp)
bp2->bio_attribute = bp->bio_attribute;
bp->bio_children++;
#ifdef KTR
- if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) {
+ if (KTR_GEOM_ENABLED) {
struct stack st;
CTR2(KTR_GEOM, "g_duplicate_bio(%p): %p", bp, bp2);