git: 739a9c51b0b4 - main - geom(4): Fix some of the "set but not used" warnings

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Sat, 18 Dec 2021 11:49:25 UTC
The branch main has been updated by trasz:

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

commit 739a9c51b0b40bae675eb3fed504ae585d40b7e5
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-12-13 15:19:56 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-12-18 11:42:34 +0000

    geom(4): Fix some of the "set but not used" warnings
    
    The few I've left in place look like potential bugs.
    
    Sponsored By:   EPSRC
---
 sys/geom/bde/g_bde.h               | 13 +++++++++----
 sys/geom/journal/g_journal.c       |  2 +-
 sys/geom/shsec/g_shsec.c           |  2 --
 sys/geom/stripe/g_stripe.c         |  2 +-
 sys/geom/vinum/geom_vinum_create.c |  3 +--
 sys/geom/vinum/geom_vinum_init.c   |  2 +-
 sys/geom/vinum/geom_vinum_plex.c   |  2 --
 sys/geom/vinum/geom_vinum_raid5.c  |  3 ---
 sys/geom/vinum/geom_vinum_rename.c |  2 +-
 sys/geom/vinum/geom_vinum_subr.c   |  2 +-
 sys/geom/vinum/geom_vinum_volume.c |  4 +---
 sys/geom/virstor/g_virstor.c       |  2 --
 12 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/sys/geom/bde/g_bde.h b/sys/geom/bde/g_bde.h
index 3f36bb4281ae..2b9cc0532ef9 100644
--- a/sys/geom/bde/g_bde.h
+++ b/sys/geom/bde/g_bde.h
@@ -57,6 +57,11 @@
 /* This just needs to be "large enough" */
 #define G_BDE_KEYBYTES	304
 
+/* This file is being included by userspace. */
+#ifndef __diagused
+#define	__diagused
+#endif
+
 struct g_bde_work;
 struct g_bde_softc;
 
@@ -176,7 +181,7 @@ void g_bde_worker(void *arg);
 static __inline void
 AES_init(cipherInstance *ci)
 {
-	int error;
+	int error __diagused;
 
 	error = rijndael_cipherInit(ci, MODE_CBC, NULL);
 	KASSERT(error > 0, ("rijndael_cipherInit %d", error));
@@ -185,7 +190,7 @@ AES_init(cipherInstance *ci)
 static __inline void
 AES_makekey(keyInstance *ki, int dir, u_int len, const void *key)
 {
-	int error;
+	int error __diagused;
 
 	error = rijndael_makeKey(ki, dir, len, key);
 	KASSERT(error > 0, ("rijndael_makeKey %d", error));
@@ -194,7 +199,7 @@ AES_makekey(keyInstance *ki, int dir, u_int len, const void *key)
 static __inline void
 AES_encrypt(cipherInstance *ci, keyInstance *ki, const void *in, void *out, u_int len)
 {
-	int error;
+	int error __diagused;
 
 	error = rijndael_blockEncrypt(ci, ki, in, len * 8, out);
 	KASSERT(error > 0, ("rijndael_blockEncrypt %d", error));
@@ -203,7 +208,7 @@ AES_encrypt(cipherInstance *ci, keyInstance *ki, const void *in, void *out, u_in
 static __inline void
 AES_decrypt(cipherInstance *ci, keyInstance *ki, const void *in, void *out, u_int len)
 {
-	int error;
+	int error __diagused;
 
 	error = rijndael_blockDecrypt(ci, ki, in, len * 8, out);
 	KASSERT(error > 0, ("rijndael_blockDecrypt %d", error));
diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c
index 954d0dbf2c6b..60c2aeb4fad6 100644
--- a/sys/geom/journal/g_journal.c
+++ b/sys/geom/journal/g_journal.c
@@ -2961,7 +2961,7 @@ next:
 static void
 g_journal_start_switcher(struct g_class *mp)
 {
-	int error;
+	int error __diagused;
 
 	g_topology_assert();
 	MPASS(g_journal_switcher_proc == NULL);
diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c
index a3b2f59d0555..65bfbc6681dd 100644
--- a/sys/geom/shsec/g_shsec.c
+++ b/sys/geom/shsec/g_shsec.c
@@ -249,11 +249,9 @@ g_shsec_xor1(uint32_t *src, uint32_t *dst, ssize_t len)
 static void
 g_shsec_done(struct bio *bp)
 {
-	struct g_shsec_softc *sc;
 	struct bio *pbp;
 
 	pbp = bp->bio_parent;
-	sc = pbp->bio_to->geom->softc;
 	if (bp->bio_error == 0)
 		G_SHSEC_LOGREQ(2, bp, "Request done.");
 	else {
diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c
index 9b4df1b8dba6..ec3bfb28b6a5 100644
--- a/sys/geom/stripe/g_stripe.c
+++ b/sys/geom/stripe/g_stripe.c
@@ -203,7 +203,7 @@ static int
 g_stripe_access(struct g_provider *pp, int dr, int dw, int de)
 {
 	struct g_consumer *cp1, *cp2, *tmp;
-	struct g_stripe_softc *sc;
+	struct g_stripe_softc *sc __diagused;
 	struct g_geom *gp;
 	int error;
 
diff --git a/sys/geom/vinum/geom_vinum_create.c b/sys/geom/vinum/geom_vinum_create.c
index 036ce82c45e8..c828fdd5ac33 100644
--- a/sys/geom/vinum/geom_vinum_create.c
+++ b/sys/geom/vinum/geom_vinum_create.c
@@ -552,11 +552,10 @@ gv_stripe(struct g_geom *gp, struct gctl_req *req)
 	struct gv_plex *p;
 	struct gv_softc *sc;
 	char *drive, buf[30], *vol;
-	int *drives, *flags, dcount, pcount;
+	int *drives, *flags, dcount;
 
 	sc = gp->softc;
 	dcount = 0;
-	pcount = 0;
 	vol = gctl_get_param(req, "name", NULL);
 	if (vol == NULL) {
 		gctl_error(req, "volume name not given");	
diff --git a/sys/geom/vinum/geom_vinum_init.c b/sys/geom/vinum/geom_vinum_init.c
index 115a3c66d445..55899b480e63 100644
--- a/sys/geom/vinum/geom_vinum_init.c
+++ b/sys/geom/vinum/geom_vinum_init.c
@@ -233,7 +233,7 @@ gv_find_good_plex(struct gv_volume *v)
 static int
 gv_sync(struct gv_volume *v)
 {
-	struct gv_softc *sc;
+	struct gv_softc *sc __diagused;
 	struct gv_plex *p, *up;
 	int error;
 
diff --git a/sys/geom/vinum/geom_vinum_plex.c b/sys/geom/vinum/geom_vinum_plex.c
index a7b1e1e5a8bd..84203fcad6c9 100644
--- a/sys/geom/vinum/geom_vinum_plex.c
+++ b/sys/geom/vinum/geom_vinum_plex.c
@@ -538,10 +538,8 @@ gv_normal_parity(struct gv_plex *p, struct bio *bp, struct gv_raid5_packet *wp)
 static void
 gv_plex_flush(struct gv_plex *p)
 {
-	struct gv_softc *sc;
 	struct bio *bp;
 
-	sc = p->vinumconf;
 	bp = bioq_takefirst(p->rqueue);
 	while (bp != NULL) {
 		gv_plex_start(p, bp);
diff --git a/sys/geom/vinum/geom_vinum_raid5.c b/sys/geom/vinum/geom_vinum_raid5.c
index 2778646467e2..43a6a8bce330 100644
--- a/sys/geom/vinum/geom_vinum_raid5.c
+++ b/sys/geom/vinum/geom_vinum_raid5.c
@@ -345,15 +345,12 @@ static int
 gv_raid5_request(struct gv_plex *p, struct gv_raid5_packet *wp,
     struct bio *bp, caddr_t addr, off_t boff, off_t bcount, int *delay)
 {
-	struct g_geom *gp;
 	struct gv_sd *broken, *original, *parity, *s;
 	struct gv_bioq *bq;
 	struct bio *cbp;
 	int i, psdno, sdno, type, grow;
 	off_t real_len, real_off;
 
-	gp = bp->bio_to->geom;
-
 	if (p == NULL || LIST_EMPTY(&p->subdisks))
 		return (ENXIO);
 
diff --git a/sys/geom/vinum/geom_vinum_rename.c b/sys/geom/vinum/geom_vinum_rename.c
index 688673268ef9..394f5afd0703 100644
--- a/sys/geom/vinum/geom_vinum_rename.c
+++ b/sys/geom/vinum/geom_vinum_rename.c
@@ -226,7 +226,7 @@ int
 gv_rename_vol(struct gv_softc *sc, struct gv_volume *v, char *newname,
     int flags)
 {
-	struct g_provider *pp;
+	struct g_provider *pp __diagused;
 	struct gv_plex *p;
 	char newplex[GV_MAXPLEXNAME], *ptr;
 	int err;
diff --git a/sys/geom/vinum/geom_vinum_subr.c b/sys/geom/vinum/geom_vinum_subr.c
index 13edf928b6ad..54dd6db95e5e 100644
--- a/sys/geom/vinum/geom_vinum_subr.c
+++ b/sys/geom/vinum/geom_vinum_subr.c
@@ -1124,7 +1124,7 @@ int
 gv_attach_plex(struct gv_plex *p, struct gv_volume *v, int rename)
 {
 	struct gv_sd *s;
-	struct gv_softc *sc;
+	struct gv_softc *sc __diagused;
 
 	g_topology_assert();
 
diff --git a/sys/geom/vinum/geom_vinum_volume.c b/sys/geom/vinum/geom_vinum_volume.c
index 63b1077a26fa..fec61ee28611 100644
--- a/sys/geom/vinum/geom_vinum_volume.c
+++ b/sys/geom/vinum/geom_vinum_volume.c
@@ -59,12 +59,10 @@ gv_volume_flush(struct gv_volume *v)
 void
 gv_volume_start(struct gv_softc *sc, struct bio *bp)
 {
-	struct g_geom *gp;
 	struct gv_volume *v;
 	struct gv_plex *p, *lp;
 	int numwrites;
 
-	gp = sc->geom;
 	v = bp->bio_to->private;
 	if (v == NULL || v->state != GV_VOL_UP) {
 		g_io_deliver(bp, ENXIO);
@@ -143,7 +141,7 @@ gv_volume_start(struct gv_softc *sc, struct bio *bp)
 void
 gv_bio_done(struct gv_softc *sc, struct bio *bp)
 {
-	struct gv_volume *v;
+	struct gv_volume *v __diagused;
 	struct gv_plex *p;
 	struct gv_sd *s;
 
diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c
index e27d92b509d4..6c201b24ab19 100644
--- a/sys/geom/virstor/g_virstor.c
+++ b/sys/geom/virstor/g_virstor.c
@@ -1528,11 +1528,9 @@ g_virstor_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
 static void
 g_virstor_done(struct bio *b)
 {
-	struct g_virstor_softc *sc;
 	struct bio *parent_b;
 
 	parent_b = b->bio_parent;
-	sc = parent_b->bio_to->geom->softc;
 
 	if (b->bio_error != 0) {
 		LOG_MSG(LVL_ERROR, "Error %d for offset=%ju, length=%ju, %s",