Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

erofs: remove more unnecessary #ifdefs

Many #ifdefs can be replaced with IS_ENABLED() to improve code
readability. No functional changes.

Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

authored by

Ferry Meng and committed by
Gao Xiang
bf4fde7d 03c0d030

+35 -48
+35 -48
fs/erofs/super.c
··· 424 424 425 425 static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode) 426 426 { 427 - #ifdef CONFIG_FS_DAX 428 - struct erofs_sb_info *sbi = fc->s_fs_info; 427 + if (IS_ENABLED(CONFIG_FS_DAX)) { 428 + struct erofs_sb_info *sbi = fc->s_fs_info; 429 429 430 - switch (mode) { 431 - case EROFS_MOUNT_DAX_ALWAYS: 432 - set_opt(&sbi->opt, DAX_ALWAYS); 433 - clear_opt(&sbi->opt, DAX_NEVER); 434 - return true; 435 - case EROFS_MOUNT_DAX_NEVER: 436 - set_opt(&sbi->opt, DAX_NEVER); 437 - clear_opt(&sbi->opt, DAX_ALWAYS); 438 - return true; 439 - default: 430 + if (mode == EROFS_MOUNT_DAX_ALWAYS) { 431 + set_opt(&sbi->opt, DAX_ALWAYS); 432 + clear_opt(&sbi->opt, DAX_NEVER); 433 + return true; 434 + } else if (mode == EROFS_MOUNT_DAX_NEVER) { 435 + set_opt(&sbi->opt, DAX_NEVER); 436 + clear_opt(&sbi->opt, DAX_ALWAYS); 437 + return true; 438 + } 440 439 DBG_BUGON(1); 441 440 return false; 442 441 } 443 - #else 444 442 errorfc(fc, "dax options not supported"); 445 443 return false; 446 - #endif 447 444 } 448 445 449 446 static int erofs_fc_parse_param(struct fs_context *fc, ··· 457 460 458 461 switch (opt) { 459 462 case Opt_user_xattr: 460 - #ifdef CONFIG_EROFS_FS_XATTR 461 - if (result.boolean) 463 + if (!IS_ENABLED(CONFIG_EROFS_FS_XATTR)) 464 + errorfc(fc, "{,no}user_xattr options not supported"); 465 + else if (result.boolean) 462 466 set_opt(&sbi->opt, XATTR_USER); 463 467 else 464 468 clear_opt(&sbi->opt, XATTR_USER); 465 - #else 466 - errorfc(fc, "{,no}user_xattr options not supported"); 467 - #endif 468 469 break; 469 470 case Opt_acl: 470 - #ifdef CONFIG_EROFS_FS_POSIX_ACL 471 - if (result.boolean) 471 + if (!IS_ENABLED(CONFIG_EROFS_FS_POSIX_ACL)) 472 + errorfc(fc, "{,no}acl options not supported"); 473 + else if (result.boolean) 472 474 set_opt(&sbi->opt, POSIX_ACL); 473 475 else 474 476 clear_opt(&sbi->opt, POSIX_ACL); 475 - #else 476 - errorfc(fc, "{,no}acl options not supported"); 477 - #endif 478 477 break; 479 478 case Opt_cache_strategy: 480 - #ifdef CONFIG_EROFS_FS_ZIP 481 - sbi->opt.cache_strategy = result.uint_32; 482 - #else 483 - errorfc(fc, "compression not supported, cache_strategy ignored"); 484 - #endif 479 + if (!IS_ENABLED(CONFIG_EROFS_FS_ZIP)) 480 + errorfc(fc, "compression not supported, cache_strategy ignored"); 481 + else 482 + sbi->opt.cache_strategy = result.uint_32; 485 483 break; 486 484 case Opt_dax: 487 485 if (!erofs_fc_set_dax_mode(fc, EROFS_MOUNT_DAX_ALWAYS)) ··· 525 533 break; 526 534 #endif 527 535 case Opt_directio: 528 - #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE 529 - if (result.boolean) 536 + if (!IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE)) 537 + errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 538 + else if (result.boolean) 530 539 set_opt(&sbi->opt, DIRECT_IO); 531 540 else 532 541 clear_opt(&sbi->opt, DIRECT_IO); 533 - #else 534 - errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 535 - #endif 536 542 break; 537 543 case Opt_fsoffset: 538 544 sbi->dif0.fsoff = result.uint_64; 539 545 break; 540 546 case Opt_inode_share: 541 - #ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE 542 - set_opt(&sbi->opt, INODE_SHARE); 543 - #else 544 - errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 545 - #endif 547 + if (!IS_ENABLED(CONFIG_EROFS_FS_PAGE_CACHE_SHARE)) 548 + errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 549 + else 550 + set_opt(&sbi->opt, INODE_SHARE); 546 551 break; 547 552 } 548 553 return 0; ··· 798 809 ret = get_tree_bdev_flags(fc, erofs_fc_fill_super, 799 810 IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) ? 800 811 GET_TREE_BDEV_QUIET_LOOKUP : 0); 801 - #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE 802 - if (ret == -ENOTBLK) { 812 + if (IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && ret == -ENOTBLK) { 803 813 struct file *file; 804 814 805 815 if (!fc->source) ··· 812 824 sbi->dif0.file->f_mapping->a_ops->read_folio) 813 825 return get_tree_nodev(fc, erofs_fc_fill_super); 814 826 } 815 - #endif 816 827 return ret; 817 828 } 818 829 ··· 1095 1108 seq_puts(seq, ",dax=never"); 1096 1109 if (erofs_is_fileio_mode(sbi) && test_opt(opt, DIRECT_IO)) 1097 1110 seq_puts(seq, ",directio"); 1098 - #ifdef CONFIG_EROFS_FS_ONDEMAND 1099 - if (sbi->fsid) 1100 - seq_printf(seq, ",fsid=%s", sbi->fsid); 1101 - if (sbi->domain_id) 1102 - seq_printf(seq, ",domain_id=%s", sbi->domain_id); 1103 - #endif 1111 + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND)) { 1112 + if (sbi->fsid) 1113 + seq_printf(seq, ",fsid=%s", sbi->fsid); 1114 + if (sbi->domain_id) 1115 + seq_printf(seq, ",domain_id=%s", sbi->domain_id); 1116 + } 1104 1117 if (sbi->dif0.fsoff) 1105 1118 seq_printf(seq, ",fsoffset=%llu", sbi->dif0.fsoff); 1106 1119 if (test_opt(opt, INODE_SHARE))