git: 87bb53cb5380 - main - gvinum: correct assertions

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 21 Mar 2023 14:03:28 UTC
The branch main has been updated by emaste:

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

commit 87bb53cb538059a3085db1fa4295dde5fcba55fe
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-12 17:08:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-21 14:03:12 +0000

    gvinum: correct assertions
    
    Pointer addresses are always >= 0.  Assert that the value is >= 0
    instead.
    
    PR:             207855, 207856
    Reviewed by:    imp
    Reported by:    David Binderman
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37677
---
 sys/geom/vinum/geom_vinum_plex.c  | 2 +-
 sys/geom/vinum/geom_vinum_raid5.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/geom/vinum/geom_vinum_plex.c b/sys/geom/vinum/geom_vinum_plex.c
index b217cff7d6ab..1f39204b9e07 100644
--- a/sys/geom/vinum/geom_vinum_plex.c
+++ b/sys/geom/vinum/geom_vinum_plex.c
@@ -173,7 +173,7 @@ gv_plex_offset(struct gv_plex *p, off_t boff, off_t bcount, off_t *real_off,
 			return (GV_ERR_ISBUSY);
 		*sdno = stripeno % sdcount;
 
-		KASSERT(sdno >= 0, ("gv_plex_offset: sdno < 0"));
+		KASSERT(*sdno >= 0, ("gv_plex_offset: sdno < 0"));
 		stripestart = (stripeno / sdcount) *
 		    p->stripesize;
 		KASSERT(stripestart >= 0, ("gv_plex_offset: stripestart < 0"));
diff --git a/sys/geom/vinum/geom_vinum_raid5.c b/sys/geom/vinum/geom_vinum_raid5.c
index 43a6a8bce330..ecc3ae99b56b 100644
--- a/sys/geom/vinum/geom_vinum_raid5.c
+++ b/sys/geom/vinum/geom_vinum_raid5.c
@@ -602,7 +602,7 @@ gv_raid5_offset(struct gv_plex *p, off_t boff, off_t bcount, off_t *real_off,
 	/* The number of the subdisk containing the parity stripe. */
 	psd = sdcount - 1 - ( boff / (p->stripesize * (sdcount - 1))) %
 	    sdcount;
-	KASSERT(psdno >= 0, ("gv_raid5_offset: psdno < 0"));
+	KASSERT(psd >= 0, ("gv_raid5_offset: psdno < 0"));
 
 	/* Offset of the start address from the start of the stripe. */
 	stripeoff = boff % (p->stripesize * (sdcount - 1));
@@ -610,7 +610,7 @@ gv_raid5_offset(struct gv_plex *p, off_t boff, off_t bcount, off_t *real_off,
 
 	/* The number of the subdisk where the stripe resides. */
 	sd = stripeoff / p->stripesize;
-	KASSERT(sdno >= 0, ("gv_raid5_offset: sdno < 0"));
+	KASSERT(sd >= 0, ("gv_raid5_offset: sdno < 0"));
 
 	/* At or past parity subdisk. */
 	if (sd >= psd)