f2fs: use *switch* statement in __is_valid_data_blkaddr()
PATCH 1/1 f2fs: use *switch* statement in __is_valid_data_blkaddr()
In __is_valid_data_blkaddr(), an *if* statement is used where a *switch* statement clearly fits better...
---
This patch is against the dev branch of Jaegeuk Kim's f2fs.git repo.
fs/f2fs/f2fs.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/f2fs/f2fs.h +7 -3
@@ -3680,10 +3680,14 @@ static inline void verify_blkaddr(struct f2fs_sb_info *sbi,static inline bool __is_valid_data_blkaddr (block_t blkaddr) { -if (blkaddr ==NEW_ADDR || blkaddr ==NULL_ADDR || - blkaddr ==COMPRESS_ADDR ) +switch (blkaddr) { +case NEW_ADDR : +case NULL_ADDR : +case COMPRESS_ADDR :return false; -return true; +default : +return true; + } }/*
Signature · 7 lines
2.52.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 2 lines · Sergey Shtylyov
In
__is_valid_data_blkaddr(), an *if* statement is used where a *switch* statement clearly fits better...
I think previous version is clear to understand, unless we add more *_ADDR. :)
Thanks,
Quoted 20 lines
Signed-off-by Sergey Shtylyov <[email protected]>---
This patch is against the dev branch of Jaegeuk Kim's f2fs.git repo.fs/f2fs/f2fs.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)fs/f2fs/f2fs.h +2
-2@@ -3680,10 +3680,14 @@ static inline void verify_blkaddr(struct f2fs_sb_info *sbi,static inline bool __is_valid_data_blkaddr (block_t blkaddr) { -if (blkaddr ==NEW_ADDR || blkaddr ==NULL_ADDR || - blkaddr ==COMPRESS_ADDR ) +switch (blkaddr) { +case NEW_ADDR :
fs/f2fs/f2fs.h static inline void verify_blkaddr(struct f2fs_sb_info *sbi, · line 3693
Quoted 10 lines
fs/f2fs/f2fs.h +5
-1+case NULL_ADDR : +case COMPRESS_ADDR :return false; -return true; +default : +return true; + } }/*
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On 12/26/25 6:01 AM, Chao Yu wrote:
[...]
Quoted 4 lines
Quoted 2 lines
In
__is_valid_data_blkaddr(), an *if* statement is used where a *switch* statement clearly fits better...I think previous version is clear to understand, unless we add more
*_ADDR. :)
And I don't think # of the *_ADDR macros matters whtn it's already > 1.
Quoted 1 line
Thanks,
[...]
MBR, Sergey
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On 12/26/25 12:12 PM, Sergey Shtylyov wrote:
[...]
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
In
__is_valid_data_blkaddr(), an *if* statement is used where a *switch* statement clearly fits better...I think previous version is clear to understand, unless we add more
*_ADDR. :)And I don't think # of the
*_ADDRmacros matters whtn it's already > 1.
s/whtn/when/.
By using a string of blkaddr comparisons you cause the compiler to do extra
work (for no good reason).
[...]
MBR, Sergey
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel