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

hfsplus: remove unnecessary variable initialization

Variables are assigned first and then used. Initialization is not
required.

[akpm@linux-foundation.org: give hfsplus_listxattr:key_len narrower scope]
Link: https://lkml.kernel.org/r/20221221032119.10037-1-xupengfei@nfschina.com
Signed-off-by: XU pengfei <xupengfei@nfschina.com>
Reviewed-by: Andrew Morton <akpm@linux-foudation.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

XU pengfei and committed by
Andrew Morton
1b2fde2d d5528cc1

+9 -9
+9 -9
fs/hfsplus/xattr.c
··· 257 257 int __hfsplus_setxattr(struct inode *inode, const char *name, 258 258 const void *value, size_t size, int flags) 259 259 { 260 - int err = 0; 260 + int err; 261 261 struct hfs_find_data cat_fd; 262 262 hfsplus_cat_entry entry; 263 263 u16 cat_entry_flags, cat_entry_type; ··· 494 494 __be32 xattr_record_type; 495 495 u32 record_type; 496 496 u16 record_length = 0; 497 - ssize_t res = 0; 497 + ssize_t res; 498 498 499 499 if ((!S_ISREG(inode->i_mode) && 500 500 !S_ISDIR(inode->i_mode)) || ··· 606 606 static ssize_t hfsplus_listxattr_finder_info(struct dentry *dentry, 607 607 char *buffer, size_t size) 608 608 { 609 - ssize_t res = 0; 609 + ssize_t res; 610 610 struct inode *inode = d_inode(dentry); 611 611 struct hfs_find_data fd; 612 612 u16 entry_type; ··· 674 674 ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size) 675 675 { 676 676 ssize_t err; 677 - ssize_t res = 0; 677 + ssize_t res; 678 678 struct inode *inode = d_inode(dentry); 679 679 struct hfs_find_data fd; 680 - u16 key_len = 0; 681 680 struct hfsplus_attr_key attr_key; 682 681 char *strbuf; 683 682 int xattr_name_len; ··· 718 719 } 719 720 720 721 for (;;) { 721 - key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset); 722 + u16 key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset); 723 + 722 724 if (key_len == 0 || key_len > fd.tree->max_key_len) { 723 725 pr_err("invalid xattr key length: %d\n", key_len); 724 726 res = -EIO; ··· 766 766 767 767 static int hfsplus_removexattr(struct inode *inode, const char *name) 768 768 { 769 - int err = 0; 769 + int err; 770 770 struct hfs_find_data cat_fd; 771 771 u16 flags; 772 772 u16 cat_entry_type; 773 - int is_xattr_acl_deleted = 0; 774 - int is_all_xattrs_deleted = 0; 773 + int is_xattr_acl_deleted; 774 + int is_all_xattrs_deleted; 775 775 776 776 if (!HFSPLUS_SB(inode->i_sb)->attr_tree) 777 777 return -EOPNOTSUPP;