Skip to contentSkip to conversation

smb: client: Simplify a return statement in get_smb2_acl_by_path()

PATCH Applied Markus Elfring 2 participants 8 messages Oct 8, 2025 – Oct 10, 2025 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smb: client: Simplify a return statement in get_smb2_acl_by_path()

From: Markus Elfring <[email protected]>
Date: Wed, 8 Oct 2025 21:56:34 +0200

Return an error pointer without referencing another local variable in an if branch of this function implementation.

---
 fs/smb/client/smb2ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/smb/client/smb2ops.c +1 -2
index 7c3e96260fd4..bb5eda032aa4 100644
@@ -3216,9 +3216,8 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
 
 	utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
 	if (!utf16_path) {
-		rc = -ENOMEM;
 		free_xid(xid);
-		return ERR_PTR(rc);
+		return ERR_PTR(-ENOMEM);
 	}
 
 	oparms = (struct cifs_open_parms) {
Signature · 1 line
2.51.0
Applied
#1 lore raw

merged into cifs-2.6.git for-next

Quoted 31 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 8 Oct 2025 21:56:34 +0200

Return an error pointer without referencing another local variable in an if branch of this function implementation.

---
 fs/smb/client/smb2ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/smb/client/smb2ops.c +1 -3
index 7c3e96260fd4..bb5eda032aa4 100644
@@ -3216,9 +3216,8 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
 
        utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
        if (!utf16_path) {
-               rc = -ENOMEM;
                free_xid(xid);
-               return ERR_PTR(rc);
+               return ERR_PTR(-ENOMEM);
        }
 
        oparms = (struct cifs_open_parms) {
--

2.51.0

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): CAH2r5mtpoLscs9sodXcRMO3-dqMDBSTR+ncExdqy4dQR=4uE8A@mail.gmail.com

#3 lore raw
Quoted 1 line

This is an example of one that is probably slightly worth it,

Thanks for such a positive indication.

Quoted 1 line

it shrinks one line of code, and also doesn't have risk,

Similar source code refinements might become also interesting and helpful.

Quoted 1 line

but at least three of the others today don't shrink and sometimes grow lines of code (and don't fix anything )

Further update candidates can be found and eventually transformed also with the help of the semantic patch language (Coccinelle software).

Quoted 1 line

so are unlikely to be worth it since they slightly increase risk of adding difficulty to stable backports of future fixes

I hope that such change resistance can be reconsidered.

Regards,
Markus

A message that is not in the archive (sent off-list or not yet received): CAH2r5mtY8--9ccnm5aYfOYJ=kEBr7=y-Z_eROKDp7A6DGnxwcA@mail.gmail.com

#5 lore raw
Quoted 1 line

Three of the four you just sent today, grow the code slightly,

How much will this observation matter?

Quoted 1 line

and don't fix anything,

Do these change suggestions indicate possible improvements according to specific design aspects?

Quoted 1 line

the remaining one could be considered

I am curious how the patch reviews will be evolving further.

Regards,
Markus

#6 lore raw
Quoted 4 lines · Markus Elfring
Quoted 2 lines

Three of the four you just sent today, grow the code slightly,

How much will this observation matter?

Remember the goals here, the priorities:
1) Fixes for bugs
2) Performance improvements
3) Features that add support for missing Linux requirements (e.g. adding O_TMPFILE or "rename_exchange support)
and then lower priority but still somewhat useful:
4) cleanup patches that remove unneeded code (although has to be balanced against how it can hurt backports of important fixes), ie cleanup that makes code *smaller* and therefore slightly easier to read and maintain
5) cleanup code that adds or updates comments clarifying confusing code

Obviously "cleanup" patches that don't shrink code are often useless (as they potentially break backports of patches for no value).

Signature · 3 lines
Thanks,

Steve
#7 lore raw
In reply to Markus Elfring

As pointed out by the kernel test robot a few minutes ago, this patch would introduce a regression (uninitialized rc variable in free_xid macro), so will remove this patch from for-next.

Quoted 31 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 8 Oct 2025 21:56:34 +0200

Return an error pointer without referencing another local variable in an if branch of this function implementation.

---
 fs/smb/client/smb2ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/smb/client/smb2ops.c +1 -3
index 7c3e96260fd4..bb5eda032aa4 100644
@@ -3216,9 +3216,8 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
 
        utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
        if (!utf16_path) {
-               rc = -ENOMEM;
                free_xid(xid);
-               return ERR_PTR(rc);
+               return ERR_PTR(-ENOMEM);
        }
 
        oparms = (struct cifs_open_parms) {
--

2.51.0

Signature · 3 lines
Thanks,

Steve
#8 lore raw
Quoted 3 lines

As pointed out by the kernel test robot a few minutes ago, this patch would introduce a regression (uninitialized rc variable in free_xid macro), so will remove this patch from for-next.

Will this (clang) compiler report be reconsidered once more under other circumstances?

…>> +++ b/fs/smb/client/smb2ops.c

Quoted 11 lines

fs/smb/client/smb2ops.c get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb, · line 3223

Quoted 11 lines
fs/smb/client/smb2ops.c +1 -2
@@ -3216,9 +3216,8 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
 
        utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
        if (!utf16_path) {
-               rc = -ENOMEM;
                free_xid(xid);
-               return ERR_PTR(rc);
+               return ERR_PTR(-ENOMEM);
        }
 
        oparms = (struct cifs_open_parms) {

…

Can it be that the uninitialized rc variable would not really matter for the adjusted statements in such an if branch?

Regards,
Markus