* [f2fs-dev] [PATCH] inject.f2fs: fix some build errors
@ 2024-07-25 18:39 Jaegeuk Kim
2024-07-29 19:20 ` Daeho Jeong
2024-07-30 19:36 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
0 siblings, 2 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2024-07-25 18:39 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
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")) {
--
2.46.0.rc1.232.g9752f9e123-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH] inject.f2fs: fix some build errors
2024-07-25 18:39 [f2fs-dev] [PATCH] inject.f2fs: fix some build errors Jaegeuk Kim
@ 2024-07-29 19:20 ` Daeho Jeong
2024-07-29 23:50 ` Jaegeuk Kim
2024-07-30 19:36 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
1 sibling, 1 reply; 5+ messages in thread
From: Daeho Jeong @ 2024-07-29 19:20 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
On Thu, Jul 25, 2024 at 11:41 AM Jaegeuk Kim <jaegeuk@kernel.org> wrote:
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> 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')
Do we support a negative value for nid?
> 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')
ditto
> 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")) {
> --
> 2.46.0.rc1.232.g9752f9e123-goog
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH] inject.f2fs: fix some build errors
2024-07-29 19:20 ` Daeho Jeong
@ 2024-07-29 23:50 ` Jaegeuk Kim
0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2024-07-29 23:50 UTC (permalink / raw)
To: Daeho Jeong; +Cc: linux-f2fs-devel
On 07/29, Daeho Jeong wrote:
> On Thu, Jul 25, 2024 at 11:41 AM Jaegeuk Kim <jaegeuk@kernel.org> wrote:
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > 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')
>
> Do we support a negative value for nid?
unsigned int?
>
> > 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')
>
> ditto
>
> > 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")) {
> > --
> > 2.46.0.rc1.232.g9752f9e123-goog
> >
> >
> >
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH v2] inject.f2fs: fix some build errors
2024-07-25 18:39 [f2fs-dev] [PATCH] inject.f2fs: fix some build errors Jaegeuk Kim
2024-07-29 19:20 ` Daeho Jeong
@ 2024-07-30 19:36 ` Jaegeuk Kim
2024-07-31 7:53 ` Chao Yu
1 sibling, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2024-07-30 19:36 UTC (permalink / raw)
To: linux-f2fs-devel
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
Change log from v1:
- check the negative values
fsck/inject.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/fsck/inject.c b/fsck/inject.c
index 2a21dae293f6..9dc085f389be 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,11 @@ 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 ||
+ nid = strtol(optarg, &endptr, 0);
+ if (nid >= UINT_MAX || nid < 0 ||
*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 +283,11 @@ 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 ||
+ blk = strtol(optarg, &endptr, 0);
+ if (blk >= UINT_MAX || blk < 0 ||
*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 +436,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 +514,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 +631,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 +756,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 +839,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 +869,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")) {
--
2.46.0.rc1.232.g9752f9e123-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH v2] inject.f2fs: fix some build errors
2024-07-30 19:36 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
@ 2024-07-31 7:53 ` Chao Yu
0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2024-07-31 7:53 UTC (permalink / raw)
To: Jaegeuk Kim, linux-f2fs-devel
On 2024/7/31 3:36, Jaegeuk Kim wrote:
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-31 7:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-25 18:39 [f2fs-dev] [PATCH] inject.f2fs: fix some build errors Jaegeuk Kim
2024-07-29 19:20 ` Daeho Jeong
2024-07-29 23:50 ` Jaegeuk Kim
2024-07-30 19:36 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
2024-07-31 7:53 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).