[PATCH] erofs-utils: mkfs: silence false-positive uninitialization warning

Gao Xiang <[email protected]> Thu, 30 Jul 2026 04:30:58 +0800
Newsgroups org.ozlabs.lists.linux-erofs
Message-ID <[email protected]>
main.c: In function 'mkfs_parse_options_cfg':
main.c:1236:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
    pclustersize_max = i;
    ~~~~~~~~~~~~~~~~~^~~

Signed-off-by: Gao Xiang <[email protected]>
---
 mkfs/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index 33c410d..929ce7c 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1228,7 +1228,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 #endif
 		case 'C':
 			err = erofs_mkfs_strtol(optarg, &endptr, &i, 0);
-			if (err < 0 || *endptr != '\0' || i <= 0) {
+			if (err || *endptr != '\0' || i <= 0) {
 				erofs_err("invalid physical clustersize %s",
 					  optarg);
 				return -EINVAL;
@@ -1250,7 +1250,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 				}
 			}
 			err = erofs_mkfs_strtol(optarg, &endptr, &i, 0);
-			if (err < 0 || (*endptr != '\0' && algid != endptr) ||
+			if (err || (*endptr != '\0' && algid != endptr) ||
 			    i <= 0) {
 				erofs_err("invalid metabox option %s", optarg);
 				return -EINVAL;
-- 
2.50.1 (Apple Git-155)