From: Andrew Morton <akpm@linux-foundation.org>
To: XU pengfei <xupengfei@nfschina.com>
Cc: keescook@chromium.org, brauner@kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] hfsplus: Remove unnecessary variable initialization
Date: Wed, 21 Dec 2022 13:37:40 -0800 [thread overview]
Message-ID: <20221221133740.fec49a9b2be29702d10ddca7@linux-foundation.org> (raw)
In-Reply-To: <20221221032119.10037-1-xupengfei@nfschina.com>
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;
_
prev parent reply other threads:[~2022-12-21 21:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-21 3:21 [PATCH 1/1] hfsplus: Remove unnecessary variable initialization XU pengfei
2022-12-21 21:37 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221221133740.fec49a9b2be29702d10ddca7@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xupengfei@nfschina.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).