lkml.org 
[lkml]   [2022]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 1/1] hfsplus: Remove unnecessary variable initialization
On Wed, 21 Dec 2022 11:21:20 +0800 XU pengfei <xupengfei@nfschina.com> wrote:

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

Looks good to me.

When making such changes I suggest you also look for opportunities to
narrow the scope of the affected variables. It makes the code easier
to read and to review.

ie,

--- a/fs/hfsplus/xattr.c~hfsplus-remove-unnecessary-variable-initialization-fix
+++ a/fs/hfsplus/xattr.c
@@ -677,7 +677,6 @@ ssize_t hfsplus_listxattr(struct dentry
ssize_t res;
struct inode *inode = d_inode(dentry);
struct hfs_find_data fd;
- u16 key_len;
struct hfsplus_attr_key attr_key;
char *strbuf;
int xattr_name_len;
@@ -719,7 +718,8 @@ ssize_t hfsplus_listxattr(struct dentry
}

for (;;) {
- key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset);
+ u16 key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset);
+
if (key_len == 0 || key_len > fd.tree->max_key_len) {
pr_err("invalid xattr key length: %d\n", key_len);
res = -EIO;
_
\
 
 \ /
  Last update: 2023-03-26 23:17    [W:0.035 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site