f2fs: use strcmp() in parse_options()
PATCH 1/1 f2fs: use strcmp() in parse_options()
From: Eric Biggers <[email protected]>
Remove the pointless string length checks. Just use strcmp().
--- fs/f2fs/super.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-)
fs/f2fs/super.c +16 -28
@@ -427,11 +427,11 @@ static int parse_options(struct super_block *sb, char *options)if (!name)return -ENOMEM ; -if (strlen (name) ==2 && !strncmp (name,"on" ,2 )) { +if (!strcmp (name,"on" )) {F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_ON ; - }else if (strlen (name) ==3 && !strncmp (name,"off" ,3 )) { + }else if (!strcmp (name,"off" )) {F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_OFF ; - }else if (strlen (name) ==4 && !strncmp (name,"sync" ,4 )) { + }else if (!strcmp (name,"sync" )) {F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_SYNC ; }else {kvfree (name);
@@ -591,16 +591,14 @@ static int parse_options(struct super_block *sb, char *options)if (!name)return -ENOMEM ; -if (strlen (name) ==8 && - !strncmp (name,"adaptive" ,8 )) { +if (!strcmp (name,"adaptive" )) {if (f2fs_sb_has_blkzoned (sbi)) {f2fs_warn (sbi,"adaptive mode is not allowed with zoned block device feature" );kvfree (name);return -EINVAL ; }F2FS_OPTION (sbi).fs_mode =FS_MODE_ADAPTIVE ; - }else if (strlen (name) ==3 && - !strncmp (name,"lfs" ,3 )) { + }else if (!strcmp (name,"lfs" )) {F2FS_OPTION (sbi).fs_mode =FS_MODE_LFS ; }else {kvfree (name);
@@ -725,14 +723,11 @@ static int parse_options(struct super_block *sb, char *options) name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ; -if (strlen (name) ==10 && - !strncmp (name,"user-based" ,10 )) { +if (!strcmp (name,"user-based" )) {F2FS_OPTION (sbi).whint_mode =WHINT_MODE_USER ; - }else if (strlen (name) ==3 && - !strncmp (name,"off" ,3 )) { + }else if (!strcmp (name,"off" )) {F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ; - }else if (strlen (name) ==8 && - !strncmp (name,"fs-based" ,8 )) { + }else if (!strcmp (name,"fs-based" )) {F2FS_OPTION (sbi).whint_mode =WHINT_MODE_FS ; }else {kvfree (name);
@@ -745,11 +740,9 @@ static int parse_options(struct super_block *sb, char *options)if (!name)return -ENOMEM ; -if (strlen (name) ==7 && - !strncmp (name,"default" ,7 )) { +if (!strcmp (name,"default" )) {F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ; - }else if (strlen (name) ==5 && - !strncmp (name,"reuse" ,5 )) { + }else if (!strcmp (name,"reuse" )) {F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_REUSE ; }else {kvfree (name);
@@ -761,14 +754,11 @@ static int parse_options(struct super_block *sb, char *options) name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ; -if (strlen (name) ==5 && - !strncmp (name,"posix" ,5 )) { +if (!strcmp (name,"posix" )) {F2FS_OPTION (sbi).fsync_mode =FSYNC_MODE_POSIX ; - }else if (strlen (name) ==6 && - !strncmp (name,"strict" ,6 )) { + }else if (!strcmp (name,"strict" )) {F2FS_OPTION (sbi).fsync_mode =FSYNC_MODE_STRICT ; - }else if (strlen (name) ==9 && - !strncmp (name,"nobarrier" ,9 )) { + }else if (!strcmp (name,"nobarrier" )) {F2FS_OPTION (sbi).fsync_mode =FSYNC_MODE_NOBARRIER ; }else {
@@ -823,15 +813,13 @@ static int parse_options(struct super_block *sb, char *options) name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ; -if (strlen (name) ==3 && !strcmp (name,"lzo" )) { +if (!strcmp (name,"lzo" )) {F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZO ; - }else if (strlen (name) ==3 && - !strcmp (name,"lz4" )) { + }else if (!strcmp (name,"lz4" )) {F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZ4 ; - }else if (strlen (name) ==4 && - !strcmp (name,"zstd" )) { + }else if (!strcmp (name,"zstd" )) {F2FS_OPTION (sbi).compress_algorithm =COMPRESS_ZSTD ; }else {
Signature · 8 lines
2.26.2 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 5 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Remove the pointless string length checks. Just use
strcmp().Signed-off-by Eric Biggers <[email protected]>
[...]
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options) · line 824
Quoted 5 lines
fs/f2fs/super.c +1
-2- }else if (strlen (name) ==4 && - !strcmp (name,"zstd" )) { + }else if (!strcmp (name,"zstd" )) {F2FS_OPTION (sbi).compress_algorithm =COMPRESS_ZSTD ;
lzo-rle will be added, Jaegeuk, please notice that the late applied patch should adjust a bit here.
Thanks,
Quoted 2 lines
} else {
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 11 lines · Chao Yu
Quoted 5 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Remove the pointless string length checks. Just use
strcmp().Signed-off-by Eric Biggers <[email protected]>Reviewed-by Chao Yu <[email protected]>[...]
Quoted 8 lines
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options) · line 824
Quoted 5 lines
fs/f2fs/super.c +1
-2- }else if (strlen (name) ==4 && - !strcmp (name,"zstd" )) { + }else if (!strcmp (name,"zstd" )) {F2FS_OPTION (sbi).compress_algorithm =COMPRESS_ZSTD ;lzo-rle will be added, Jaegeuk, please notice that the late applied patch should adjust a bit here.
Sure.
Quoted 11 lines
Thanks,
Quoted 2 lines
} else {
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel