git: 8a77bc5e1be1 - main - makefs/zfs: fix build with gcc 12 after b5a2bf512dbe

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 30 Sep 2023 18:31:26 UTC
The branch main has been updated by dim:

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

commit 8a77bc5e1be1a999f2f8d9df0c01fe01fb5a0787
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-09-30 18:27:20 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-09-30 18:27:20 +0000

    makefs/zfs: fix build with gcc 12 after b5a2bf512dbe
    
    Due to integer promotion rules, dn_nlevels (uint8_t) gets promoted to a
    plain int, resulting in -Werror warnings with gcc 12:
    
      In file included from /workspace/src/usr.sbin/makefs/zfs.c:35:
      /workspace/src/usr.sbin/makefs/zfs.c: In function '_dnode_cursor_flush':
      /workspace/src/usr.sbin/makefs/zfs.c:684:23: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
        684 |         assert(levels <= c->dnode->dn_nlevels - 1);
            |                       ^~
      /workspace/src/usr.sbin/makefs/zfs.c:691:27: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
        691 |                 if (level == c->dnode->dn_nlevels - 1) {
            |                           ^~
      /workspace/src/usr.sbin/makefs/zfs.c: In function 'dnode_cursor_next':
      /workspace/src/usr.sbin/makefs/zfs.c:739:41: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
        739 |                 for (levels = 0; levels < c->dnode->dn_nlevels - 1; levels++) {
            |                                         ^
    
    Fix it by subtracting 1U instead of 1.
    
    Fixes:          b5a2bf512dbe
    MFC after:      3 days
---
 usr.sbin/makefs/zfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/makefs/zfs.c b/usr.sbin/makefs/zfs.c
index db302fe1e760..b16a48564f04 100644
--- a/usr.sbin/makefs/zfs.c
+++ b/usr.sbin/makefs/zfs.c
@@ -681,14 +681,14 @@ _dnode_cursor_flush(zfs_opt_t *zfs, struct dnode_cursor *c, unsigned int levels)
 	off_t blkid, blksz, loc;
 
 	assert(levels > 0);
-	assert(levels <= c->dnode->dn_nlevels - 1);
+	assert(levels <= c->dnode->dn_nlevels - 1U);
 
 	blksz = MAXBLOCKSIZE;
 	blkid = (c->dataoff / c->datablksz) / BLKPTR_PER_INDIR;
 	for (unsigned int level = 1; level <= levels; level++) {
 		buf = c->inddir[level - 1];
 
-		if (level == c->dnode->dn_nlevels - 1) {
+		if (level == c->dnode->dn_nlevels - 1U) {
 			pbp = &c->dnode->dn_blkptr[0];
 		} else {
 			uint64_t iblkid;
@@ -736,7 +736,7 @@ dnode_cursor_next(zfs_opt_t *zfs, struct dnode_cursor *c, off_t off)
 	/* Do we need to flush any full indirect blocks? */
 	if (off > 0) {
 		blkid = off / c->datablksz;
-		for (levels = 0; levels < c->dnode->dn_nlevels - 1; levels++) {
+		for (levels = 0; levels < c->dnode->dn_nlevels - 1U; levels++) {
 			if (blkid % BLKPTR_PER_INDIR != 0)
 				break;
 			blkid /= BLKPTR_PER_INDIR;