From patchwork Thu Jul 25 18:39:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13742088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4FDEC3DA5D for ; Thu, 25 Jul 2024 18:39:54 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sX3NZ-0001kY-B8; Thu, 25 Jul 2024 18:39:52 +0000 Received: from [172.30.29.67] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sX3NY-0001kS-D9 for linux-f2fs-devel@lists.sourceforge.net; Thu, 25 Jul 2024 18:39:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ett5PzhDuG419l00fA1V98eEF8nQ7SW/myeQLHm7Kmg=; b=OrJASHpEn8xWJck/enci1AL0LE ByJWhgx1sWn4Vc0k66UdpHbBXKUvsyfR3Zv2ufk9+QHBFQQN6cJIe71m7pmJWQnvZp61WrH4P0z6e IuwPmDEDip6CZaUfsQRffJeE0HYu/mOiZA0PLSSReZ/SHgiRRjtNL1jVjztgNkJFMz1Y=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=ett5PzhDuG419l00fA1V98eEF8nQ7SW/myeQLHm7Kmg=; b=G aaAagLEEtq9bFSK0sg0eg0NnaI58hmBMWq6RZiIja1r10UfK5zyAPEFjIx8DunpIYgPZ1Zm5Oz3Fp Gx5IlmTK4CRGTNkgYYT8taQJ9MqQ0hh5kKxEsQPHFWrNZW2dcNz7KMTccDCRtnAOKguBOwZW1aItL fDht2wsn6N05PFaU=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sX3NW-0002b8-NH for linux-f2fs-devel@lists.sourceforge.net; Thu, 25 Jul 2024 18:39:51 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 0B2C6CE11C4 for ; Thu, 25 Jul 2024 18:39:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 406FAC116B1; Thu, 25 Jul 2024 18:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721932783; bh=xKTlnWYyf5DCq8YNjso4UaUHl1+arRmwm8nOCn7EuSw=; h=From:To:Cc:Subject:Date:From; b=I4Qrc7c21I07tMbEeiO7L/Y+viG05osGtekqrAiJh5DPWB1y6Zdws7cYbtsYD6m/8 aSiuk/qL6okgt58rZCoeIxd6opTHtoPf8PLUdqOSzbcNzm7g/sv7R7ExNnC6wvHJq8 HEg+SibUCLJh4M04NrBTucEdvJF+05cwufjfYjEtF1AS8CBjCQKcvN62Hz3KITsXAn qDNoj76P1+WYEoXghJYIarWNTnJf/j+ni5MBjBIo4B6g1VxLKUKnBNGktt//Rr7wph gvB+kzJuehwgQPDzbyObTR2NKt5eICujIMEsKEWw7w0MoOhcp3iYWwq06Y8eBHZwO7 4WVD6VT4Vvn5g== From: Jaegeuk Kim To: linux-f2fs-devel@lists.sourceforge.net Date: Thu, 25 Jul 2024 18:39:41 +0000 Message-ID: <20240725183941.655356-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog MIME-Version: 1.0 X-Headers-End: 1sX3NW-0002b8-NH Subject: [f2fs-dev] [PATCH] inject.f2fs: fix some build errors X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Signed-off-by: Jaegeuk Kim Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu --- fsck/inject.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/fsck/inject.c b/fsck/inject.c index 2a21dae293f6..4ffdfd0f0b5d 100644 --- a/fsck/inject.c +++ b/fsck/inject.c @@ -211,6 +211,8 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) while ((o = getopt_long(argc, argv, option_string, long_opt, NULL)) != EOF) { + long nid, blk; + switch (o) { case 1: c.dry_run = 1; @@ -265,10 +267,10 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) MSG(0, "Info: inject nat pack %s\n", pack[opt->nat]); break; case 9: - opt->nid = strtol(optarg, &endptr, 0); - if (opt->nid == LONG_MAX || opt->nid == LONG_MIN || - *endptr != '\0') + nid = strtol(optarg, &endptr, 0); + if (nid >= UINT_MAX || *endptr != '\0') return -ERANGE; + opt->nid = nid; MSG(0, "Info: inject nid %u : 0x%x\n", opt->nid, opt->nid); break; case 10: @@ -280,10 +282,10 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) MSG(0, "Info: inject sit pack %s\n", pack[opt->sit]); break; case 11: - opt->blk = strtol(optarg, &endptr, 0); - if (opt->blk == LONG_MAX || opt->blk == LONG_MIN || - *endptr != '\0') + blk = strtol(optarg, &endptr, 0); + if (blk >= UINT_MAX || *endptr != '\0') return -ERANGE; + opt->blk = blk; MSG(0, "Info: inject blkaddr %u : 0x%x\n", opt->blk, opt->blk); break; case 12: @@ -432,7 +434,7 @@ static int inject_cp(struct f2fs_sb_info *sbi, struct inject_option *opt) } if (!strcmp(opt->mb, "checkpoint_ver")) { - MSG(0, "Info: inject checkpoint_ver of cp %d: 0x%llx -> 0x%lx\n", + MSG(0, "Info: inject checkpoint_ver of cp %d: 0x%llx -> 0x%"PRIx64"\n", opt->cp, get_cp(checkpoint_ver), (u64)opt->val); set_cp(checkpoint_ver, (u64)opt->val); } else if (!strcmp(opt->mb, "ckpt_flags")) { @@ -510,7 +512,7 @@ static int inject_nat(struct f2fs_sb_info *sbi, struct inject_option *opt) int ret; if (!IS_VALID_NID(sbi, opt->nid)) { - ERR_MSG("Invalid nid %u range [%u:%lu]\n", opt->nid, 0, + ERR_MSG("Invalid nid %u range [%u:%"PRIu64"]\n", opt->nid, 0, NAT_ENTRY_PER_BLOCK * ((get_sb(segment_count_nat) << 1) << sbi->log_blocks_per_seg)); @@ -627,7 +629,7 @@ static int inject_sit(struct f2fs_sb_info *sbi, struct inject_option *opt) sit->valid_map[opt->idx] = (u8)opt->val; } else if (!strcmp(opt->mb, "mtime")) { MSG(0, "Info: inject sit entry mtime of block 0x%x " - "in pack %d: %lu -> %lu\n", opt->blk, opt->sit, + "in pack %d: %"PRIu64" -> %"PRIu64"\n", opt->blk, opt->sit, le64_to_cpu(sit->mtime), (u64)opt->val); sit->mtime = cpu_to_le64((u64)opt->val); } else { @@ -752,11 +754,11 @@ static int inject_inode(struct f2fs_sb_info *sbi, struct f2fs_node *node, opt->nid, le32_to_cpu(inode->i_links), (u32)opt->val); inode->i_links = cpu_to_le32((u32)opt->val); } else if (!strcmp(opt->mb, "i_size")) { - MSG(0, "Info: inject inode i_size of nid %u: %lu -> %lu\n", + MSG(0, "Info: inject inode i_size of nid %u: %"PRIu64" -> %"PRIu64"\n", opt->nid, le64_to_cpu(inode->i_size), (u64)opt->val); inode->i_size = cpu_to_le64((u64)opt->val); } else if (!strcmp(opt->mb, "i_blocks")) { - MSG(0, "Info: inject inode i_blocks of nid %u: %lu -> %lu\n", + MSG(0, "Info: inject inode i_blocks of nid %u: %"PRIu64" -> %"PRIu64"\n", opt->nid, le64_to_cpu(inode->i_blocks), (u64)opt->val); inode->i_blocks = cpu_to_le64((u64)opt->val); } else if (!strcmp(opt->mb, "i_extra_isize")) { @@ -835,7 +837,7 @@ static int inject_node(struct f2fs_sb_info *sbi, struct inject_option *opt) int ret; if (!IS_VALID_NID(sbi, opt->nid)) { - ERR_MSG("Invalid nid %u range [%u:%lu]\n", opt->nid, 0, + ERR_MSG("Invalid nid %u range [%u:%"PRIu64"]\n", opt->nid, 0, NAT_ENTRY_PER_BLOCK * ((get_sb(segment_count_nat) << 1) << sbi->log_blocks_per_seg)); @@ -865,7 +867,7 @@ static int inject_node(struct f2fs_sb_info *sbi, struct inject_option *opt) footer->flag = cpu_to_le32((u32)opt->val); } else if (!strcmp(opt->mb, "cp_ver")) { MSG(0, "Info: inject node footer cp_ver of nid %u: " - "0x%lx -> 0x%lx\n", opt->nid, le64_to_cpu(footer->cp_ver), + "0x%"PRIx64" -> 0x%"PRIx64"\n", opt->nid, le64_to_cpu(footer->cp_ver), (u64)opt->val); footer->cp_ver = cpu_to_le64((u64)opt->val); } else if (!strcmp(opt->mb, "next_blkaddr")) {