Skip to contentSkip to conversation

fs/cifs/cifsacl.c: remove set but not used variables 'rc'

PATCH In review zhengbin 3 participants 3 messages Aug 22, 2019 – Sep 9, 2019

Subsystems (2)
lore
Share & tools
lore

zhengbin

author
#0 lore raw

PATCH 1/1 fs/cifs/cifsacl.c: remove set but not used variables 'rc'

Fixes gcc '-Wunused-but-set-variable' warning:

fs/cifs/cifsacl.c: In function sid_to_id:
fs/cifs/cifsacl.c:347:6: warning: variable rc set but not used [-Wunused-but-set-variable]

---
 fs/cifs/cifsacl.c | 3 ---
 1 file changed, 3 deletions(-)
fs/cifs/cifsacl.c +0 -3
index 1d377b7..2b34337 100644
@@ -344,7 +344,6 @@ static int
 sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
 		struct cifs_fattr *fattr, uint sidtype)
 {
-	int rc;
 	struct key *sidkey;
 	char *sidstr;
 	const struct cred *saved_cred;
@@ -405,7 +404,6 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
 	saved_cred = override_creds(root_cred);
 	sidkey = request_key(&cifs_idmap_key_type, sidstr, "");
 	if (IS_ERR(sidkey)) {
-		rc = -EINVAL;
 		cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n",
 			 __func__, sidstr, sidtype == SIDOWNER ? 'u' : 'g');
 		goto out_revert_creds;
@@ -418,7 +416,6 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
 	 */
 	BUILD_BUG_ON(sizeof(uid_t) != sizeof(gid_t));
 	if (sidkey->datalen != sizeof(uid_t)) {
-		rc = -EIO;
 		cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n",
 			 __func__, sidkey->datalen);
 		key_invalidate(sidkey);

--
2.7.4

#1 lore raw

Isn't this a different bug - we set rc to -EINVAL but then don't return rc, we return 0 which looks wrong.

Quoted 43 lines · zhengbin

Fixes gcc '-Wunused-but-set-variable' warning:

fs/cifs/cifsacl.c: In function sid_to_id:
fs/cifs/cifsacl.c:347:6: warning: variable rc set but not used [-Wunused-but-set-variable]

---
 fs/cifs/cifsacl.c | 3 ---
 1 file changed, 3 deletions(-)
fs/cifs/cifsacl.c +0 -4
index 1d377b7..2b34337 100644
@@ -344,7 +344,6 @@ static int
 sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
                struct cifs_fattr *fattr, uint sidtype)
 {
-       int rc;
        struct key *sidkey;
        char *sidstr;
        const struct cred *saved_cred;
@@ -405,7 +404,6 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
        saved_cred = override_creds(root_cred);
        sidkey = request_key(&cifs_idmap_key_type, sidstr, "");
        if (IS_ERR(sidkey)) {
-               rc = -EINVAL;
                cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n",
                         __func__, sidstr, sidtype == SIDOWNER ? 'u' : 'g');
                goto out_revert_creds;
@@ -418,7 +416,6 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
         */
        BUILD_BUG_ON(sizeof(uid_t) != sizeof(gid_t));
        if (sidkey->datalen != sizeof(uid_t)) {
-               rc = -EIO;
                cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n",
                         __func__, sidkey->datalen);
                key_invalidate(sidkey);
--

2.7.4

Signature · 3 lines
Thanks,

Steve
#2 lore raw

Yes, it looks like a bug: we should initialize rc=0 at the beginning of the function and then return it at the end. Otherwise the errors are being hidden.

--
Best regards,
Pavel Shilovsky

ср, 21 авг. 2019 г. в 21:17, Steve French <[email protected]>:

Quoted 54 lines

Isn't this a different bug - we set rc to -EINVAL but then don't return rc, we return 0 which looks wrong.

Quoted 41 lines · zhengbin

Fixes gcc '-Wunused-but-set-variable' warning:

fs/cifs/cifsacl.c: In function sid_to_id:
fs/cifs/cifsacl.c:347:6: warning: variable rc set but not used [-Wunused-but-set-variable]

---
 fs/cifs/cifsacl.c | 3 ---
 1 file changed, 3 deletions(-)
fs/cifs/cifsacl.c +0 -4
index 1d377b7..2b34337 100644
@@ -344,7 +344,6 @@ static int
 sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
                struct cifs_fattr *fattr, uint sidtype)
 {
-       int rc;
        struct key *sidkey;
        char *sidstr;
        const struct cred *saved_cred;
@@ -405,7 +404,6 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
        saved_cred = override_creds(root_cred);
        sidkey = request_key(&cifs_idmap_key_type, sidstr, "");
        if (IS_ERR(sidkey)) {
-               rc = -EINVAL;
                cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n",
                         __func__, sidstr, sidtype == SIDOWNER ? 'u' : 'g');
                goto out_revert_creds;
@@ -418,7 +416,6 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
         */
        BUILD_BUG_ON(sizeof(uid_t) != sizeof(gid_t));
        if (sidkey->datalen != sizeof(uid_t)) {
-               rc = -EIO;
                cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n",
                         __func__, sidkey->datalen);
                key_invalidate(sidkey);
--
Quoted 2 lines

2.7.4

--
Thanks,

Steve