2023-09-01 08:41:38

by Li zeming

[permalink] [raw]
Subject: [PATCH] net/socket: Remove unnecessary ‘0’ values from used

used is assigned first, so it does not need to initialize the
assignment.

Signed-off-by: Li zeming <[email protected]>
---
net/socket.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index 2b0e54b2405c..743e54eba06f 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -569,12 +569,12 @@ static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,
size_t size)
{
ssize_t len;
- ssize_t used = 0;
+ ssize_t used;

len = security_inode_listsecurity(d_inode(dentry), buffer, size);
if (len < 0)
return len;
- used += len;
+ used = len;
if (buffer) {
if (size < used)
return -ERANGE;
--
2.18.2



2023-09-04 11:46:33

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] net/socket: Remove unnecessary ‘0’ values from used

On Sun, 3 Sep 2023 02:22:28 +0800 Li zeming wrote:
> used is assigned first, so it does not need to initialize the
> assignment.

It's a perfectly legitimate code pattern.
Please do not post any such patches to networking.

Please make sure you have read this:
https://docs.kernel.org/process/researcher-guidelines.html
--
pw-bot: reject