git: 2fe5f406dcc1 - stable/14 - makefs/zfs: Use unsigned integers for indirect block level counts

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 25 Oct 2023 15:26:45 UTC
The branch stable/14 has been updated by markj:

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

commit 2fe5f406dcc15da2ce3c74fd43a8777102a9f191
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-09-27 15:47:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-25 15:24:43 +0000

    makefs/zfs: Use unsigned integers for indirect block level counts
    
    No functional change intended.
    
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit b5a2bf512dbe5bc8535e28e9f584a08444965426)
---
 usr.sbin/makefs/zfs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/makefs/zfs.c b/usr.sbin/makefs/zfs.c
index 4d45926fb33f..db302fe1e760 100644
--- a/usr.sbin/makefs/zfs.c
+++ b/usr.sbin/makefs/zfs.c
@@ -673,7 +673,7 @@ dnode_cursor_init(zfs_opt_t *zfs, zfs_objset_t *os, dnode_phys_t *dnode,
 }
 
 static void
-_dnode_cursor_flush(zfs_opt_t *zfs, struct dnode_cursor *c, int levels)
+_dnode_cursor_flush(zfs_opt_t *zfs, struct dnode_cursor *c, unsigned int levels)
 {
 	blkptr_t *bp, *pbp;
 	void *buf;
@@ -685,7 +685,7 @@ _dnode_cursor_flush(zfs_opt_t *zfs, struct dnode_cursor *c, int levels)
 
 	blksz = MAXBLOCKSIZE;
 	blkid = (c->dataoff / c->datablksz) / BLKPTR_PER_INDIR;
-	for (int level = 1; level <= levels; level++) {
+	for (unsigned int level = 1; level <= levels; level++) {
 		buf = c->inddir[level - 1];
 
 		if (level == c->dnode->dn_nlevels - 1) {
@@ -724,7 +724,7 @@ blkptr_t *
 dnode_cursor_next(zfs_opt_t *zfs, struct dnode_cursor *c, off_t off)
 {
 	off_t blkid, l1id;
-	int levels;
+	unsigned int levels;
 
 	if (c->dnode->dn_nlevels == 1) {
 		assert(off < MAXBLOCKSIZE);
@@ -753,8 +753,9 @@ dnode_cursor_next(zfs_opt_t *zfs, struct dnode_cursor *c, off_t off)
 void
 dnode_cursor_finish(zfs_opt_t *zfs, struct dnode_cursor *c)
 {
-	int levels;
+	unsigned int levels;
 
+	assert(c->dnode->dn_nlevels > 0);
 	levels = c->dnode->dn_nlevels - 1;
 	if (levels > 0)
 		_dnode_cursor_flush(zfs, c, levels);