f2fs-toos:fsck.f2fs Fix bad return value
PATCH 1/1 f2fs-toos:fsck.f2fs Fix bad return value
'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from main().
--- fsck/fsck.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fsck/fsck.c +1 -2
@@ -3137,8 +3137,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)char ans[255 ] = {0 };printf ("\nDo you want to restore lost files into ./lost_found/? [Y/N] " ); - ret =scanf ("%s" , ans); -ASSERT (ret >=0 ); +ASSERT (scanf ("%s" , ans) >=0 );if (!strcasecmp (ans,"y" )) {for (i =0 ; i < fsck->nr_nat_entries; i++) {if (f2fs_test_bit (i, fsck->nat_area_bitmap))
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
Quoted 4 lines · On 2020/10/26 17:40, Robin Hsu via Linux-f2fs-devel wrote:
'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from
main().Signed-off-by Robin Hsu <[email protected]>
BTW, how about changing 'ret = EXIT_ERR_CODE' to
'ret = FSCK_ERRORS_LEFT_UNCORRECTED', it's not critical though.
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 10 lines · Chao Yu
Quoted 4 lines · On 2020/10/26 17:40, Robin Hsu via Linux-f2fs-devel wrote:
'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from
main().Signed-off-by Robin Hsu <[email protected]>BTW, how about changing 'ret =
EXIT_ERR_CODE' to
'ret =FSCK_ERRORS_LEFT_UNCORRECTED', it's not critical though.Reviewed-by Chao Yu <[email protected]>
I think it'd be good to go as is for now. :)
Quoted 2 lines
Thanks,
Quoted 13 lines · On Mon, Oct 26, 2020 at 05:40:00PM +0800, Robin Hsu via Linux-f2fs-devel wrote:
'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from
main().Signed-off-by Robin Hsu <[email protected]>--- fsck/fsck.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fsck/fsck.c +0
-0
fsck/fsck.c int fsck_verify(struct f2fs_sb_info *sbi) · line 3143
Quoted 9 lines
fsck/fsck.c +1
-2@@ -3137,8 +3137,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)char ans[255 ] = {0 };printf ("\nDo you want to restore lost files into ./lost_found/? [Y/N] " ); - ret =scanf ("%s" , ans); -ASSERT (ret >=0 ); +ASSERT (scanf ("%s" , ans) >=0 );if (!strcasecmp (ans,"y" )) {for (i =0 ; i < fsck->nr_nat_entries; i++) {if (f2fs_test_bit (i, fsck->nat_area_bitmap))
This patch causes a compiler warning:
In file included from f2fs.h:33,
from fsck.h:14,
from fsck.c:11:
fsck.c: In function 'fsck_verify':
../include/f2fs_fs.h:197:11: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
printf("[ASSERT] (%s:%4d) " #exp"\n", \
^~~~~~~~~~~~~~~~~~~~
fsck.c:3151:3: note: in expansion of macro 'ASSERT'
ASSERT(scanf("%s", ans) >= 0);
^~~~~~Jaegeuk Kim
Reviewed-by Chao YuQuoted 26 lines · Eric Biggers
Quoted 13 lines · On Mon, Oct 26, 2020 at 05:40:00PM +0800, Robin Hsu via Linux-f2fs-devel wrote:
'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from
main().Signed-off-by Robin Hsu <[email protected]>--- fsck/fsck.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fsck/fsck.c +0
-0fsck/fsck.c int fsck_verify(struct f2fs_sb_info *sbi) · line 3143
Quoted 9 lines
fsck/fsck.c +1
-2@@ -3137,8 +3137,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)char ans[255 ] = {0 };printf ("\nDo you want to restore lost files into ./lost_found/? [Y/N] " ); - ret =scanf ("%s" , ans); -ASSERT (ret >=0 ); +ASSERT (scanf ("%s" , ans) >=0 );if (!strcasecmp (ans,"y" )) {for (i =0 ; i < fsck->nr_nat_entries; i++) {if (f2fs_test_bit (i, fsck->nat_area_bitmap))This patch causes a compiler warning:
Quoted 10 lines
In file included from f2fs.h:33,
from fsck.h:14,
from fsck.c:11:
fsck.c: In function 'fsck_verify':
../include/f2fs_fs.h:197:11: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
printf("[ASSERT] (%s:%4d) " #exp"\n", \
^~~~~~~~~~~~~~~~~~~~
fsck.c:3151:3: note: in expansion of macro 'ASSERT'
ASSERT(scanf("%s", ans) >= 0);
^~~~~~Urg. Fixed by this.
From c986140e3c5abb9eb7a08928a88acb8273f1bd52 Mon Sep 17 00:00:00 2001
From: Robin Hsu <[email protected]>
Date: Mon, 26 Oct 2020 17:40:00 +0800
Subject: [PATCH] f2fs-toos: fsck.f2fs Fix bad return value
'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from main().
--- fsck/fsck.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fsck/fsck.c +3 -2
@@ -3146,10 +3146,11 @@ int fsck_verify(struct f2fs_sb_info *sbi)#ifndef WITH_ANDROID if (nr_unref_nid && !c.ro) {char ans[255 ] = {0 }; +int res;printf ("\nDo you want to restore lost files into ./lost_found/? [Y/N] " ); - ret =scanf ("%s" , ans); -ASSERT (ret >=0 ); + res =scanf ("%s" , ans); +ASSERT (res >=0 );if (!strcasecmp (ans,"y" )) {for (i =0 ; i < fsck->nr_nat_entries; i++) {if (f2fs_test_bit (i, fsck->nat_area_bitmap))
Signature · 1 line
2.29.1.341.ge80a0c044ae-goog
A message that is not in the archive (sent off-list or not yet received): CAH7-xNRd1QBJUaxajijjrMbWdKKO1AKS2-1Q5HAAkHSUF628ug@mail.gmail.com
Jaegeuk Kim
AppliedQuoted 16 lines · Robin Hsu
The root cause is the
ASSERT()marco, In fact, I already fixed it in one of my recent work.
I separate it as an independent commit here:Quoted 1 line
From
5359588b1804c5e555e9fad92203d76041ef09ebMon Sep 17 00:00:00 2001From: Robin Hsu <[email protected]>
Date: Wed, 4 Nov 2020 10:50:28 +0800
Subject: [PATCH] Fix
ASSERT()macro with '%' in the expressionFix a compiling error triggered by ASSERT(exp), when exp contains '%'
Quoted 7 lines
(e.g. integer modular operator)
Signed-off-by Robin Hsu <[email protected]>Change-Id: I84708dbaf10c675b9950926c9b6ded5b5a3fbd59
Thanks, applied as well. :)
Quoted 130 lines
---
include/f2fs_fs.h | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)include/f2fs_fs.h +0
-0index b5bda13..1348e39 100644
---
a/include/f2fs_fs.h+++
b/include/f2fs_fs.hinclude/f2fs_fs.h +2
-3@@ -194,8 +194,8 @@ static inline uint64_t bswap_64(uint64_t val)#define ASSERT (exp) \ do { \if (!(exp)) { \ - printf("[ASSERT] (%s:%4d) " #exp"\n", \ - __func__, __LINE__); \ +printf ("[ASSERT] (%s:%4d) %s\n" , \ + __func__, __LINE__, #exp); \exit (-1 ); \ } \ }while (0 ) --2.29.1.341.ge80a0c044ae-goog
Quoted 84 lines · Jaegeuk Kim
Quoted 1 line · Eric Biggers
On Mon, Oct 26, 2020 at 05:40:00PM +0800, Robin Hsu via Linux-f2fs-devel
Quoted 1 line · wrote:
Quoted 1 line
'ret' should not have been used here: otherwise, it would be wrongly
used
Quoted 7 lines
Quoted 7 lines
as the error code and then be returned from
main().Signed-off-by Robin Hsu <[email protected]>--- fsck/fsck.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Quoted 8 lines
fsck/fsck.c int fsck_verify(struct f2fs_sb_info *sbi) · line 3139
Quoted 8 lines
fsck/fsck.c +0
-0@@ -3137,8 +3137,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)char ans[255 ] = {0 }; printf("\nDo you want to restore lost files into./lost_found/? [Y/N] ");
Quoted 6 lines
fsck/fsck.c int fsck_verify(struct f2fs_sb_info *sbi)
Quoted 6 lines
fsck/fsck.c +1
-2- ret =scanf ("%s" , ans); -ASSERT (ret >=0 ); +ASSERT (scanf ("%s" , ans) >=0 );if (!strcasecmp (ans,"y" )) {for (i =0 ; i < fsck->nr_nat_entries; i++) { if (f2fs_test_bit(i,
fsck->nat_area_bitmap))Quoted 8 lines
This patch causes a compiler warning:
In file included from f2fs.h:33, from fsck.h:14, from fsck.c:11: fsck.c: In function 'fsck_verify': ../include/f2fs_fs.h:197:11: warning: format '%s' expects amatching 'char *' argument [-Wformat=]
Quoted 5 lines
printf("[ASSERT] (%s:%4d) " #exp"\n", \ ^~~~~~~~~~~~~~~~~~~~ fsck.c:3151:3: note: in expansion of macro 'ASSERT' ASSERT(scanf("%s", ans) >= 0); ^~~~~~Urg. Fixed by this.
From
c986140e3c5abb9eb7a08928a88acb8273f1bd52Mon Sep 17 00:00:00 2001
From: Robin Hsu <[email protected]>
Date: Mon, 26 Oct 2020 17:40:00 +0800
Subject: [PATCH] f2fs-toos: fsck.f2fs Fix bad return value'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from
main().Signed-off-by Robin Hsu <[email protected]>Reviewed-by Chao Yu <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>--- fsck/fsck.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fsck/fsck.c +3
-2@@ -3146,10 +3146,11 @@ int fsck_verify(struct f2fs_sb_info *sbi)#ifndef WITH_ANDROID if (nr_unref_nid && !c.ro) {char ans[255 ] = {0 }; +int res; printf("\nDo you want to restore lost files into ./lost_found/? [Y/N] "); - ret =scanf ("%s" , ans); -ASSERT (ret >=0 ); + res =scanf ("%s" , ans); +ASSERT (res >=0 );if (!strcasecmp (ans,"y" )) {for (i =0 ; i < fsck->nr_nat_entries; i++) {if (f2fs_test_bit(i,
fsck->nat_area_bitmap))
--
2.29.1.341.ge80a0c044ae-goog