Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Sep 2023 07:09:45 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: c3e092dacbc8 - stable/13 - Fix geom build with clang 17 and KTR enabled
Message-ID:  <202309200709.38K79jKx054079@gitrepo.freebsd.org>

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

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

commit c3e092dacbc8ba38c0be175f95403b3b15da736f
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-09-12 06:52:31 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-09-20 07:04:02 +0000

    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)
---
 sys/geom/geom_io.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index 70c5809ae8eb..914b5807e6e0 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -67,6 +67,9 @@
 #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;
@@ -141,7 +144,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);
@@ -159,7 +162,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);
@@ -174,7 +177,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);
@@ -219,7 +222,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);
@@ -248,7 +251,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);



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