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

Message ID 1566447421-16203-1-git-send-email-zhengbin13@huawei.com
State New
Headers show
Series
  • fs/cifs/cifsacl.c: remove set but not used variables 'rc'
Related show

Commit Message

zhengbin Aug. 22, 2019, 4:17 a.m. UTC
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]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 fs/cifs/cifsacl.c | 3 ---
 1 file changed, 3 deletions(-)

--
2.7.4

Comments

Steve French Aug. 22, 2019, 4:15 a.m. UTC | #1
Isn't this a different bug - we set rc to -EINVAL but then don't
return rc, we return 0 which looks wrong.

On Wed, Aug 21, 2019 at 11:11 PM zhengbin <zhengbin13@huawei.com> wrote:
>
> 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]
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  fs/cifs/cifsacl.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
> index 1d377b7..2b34337 100644
> --- a/fs/cifs/cifsacl.c
> +++ b/fs/cifs/cifsacl.c
> @@ -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
>
Pavel Shilovsky Sept. 9, 2019, 5:30 p.m. UTC | #2
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 <smfrench@gmail.com>:
>
> Isn't this a different bug - we set rc to -EINVAL but then don't
> return rc, we return 0 which looks wrong.
>
> On Wed, Aug 21, 2019 at 11:11 PM zhengbin <zhengbin13@huawei.com> wrote:
> >
> > 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]
> >
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: zhengbin <zhengbin13@huawei.com>
> > ---
> >  fs/cifs/cifsacl.c | 3 ---
> >  1 file changed, 3 deletions(-)
> >
> > diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
> > index 1d377b7..2b34337 100644
> > --- a/fs/cifs/cifsacl.c
> > +++ b/fs/cifs/cifsacl.c
> > @@ -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
> >
>
>
> --
> Thanks,
>
> Steve

Patch
diff mbox series

diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 1d377b7..2b34337 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -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);