HomeFreeBSD

makefs/zfs: fix build with gcc 12 after b5a2bf512dbe

Description

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

(cherry picked from commit 8a77bc5e1be1a999f2f8d9df0c01fe01fb5a0787)

Details

Provenance
dimAuthored on Sep 30 2023, 6:27 PM
markjCommitted on Oct 25 2023, 3:24 PM
Parents
rG2fe5f406dcc1: makefs/zfs: Use unsigned integers for indirect block level counts
Branches
Unknown
Tags
Unknown