Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
* Re: [PATCH] fs/cifs/cifsacl.c: remove set but not used variables 'rc'
  2019-08-22  4:17 [PATCH] fs/cifs/cifsacl.c: remove set but not used variables 'rc' zhengbin
@ 2019-08-22  4:15 ` Steve French
  2019-09-09 17:30   ` Pavel Shilovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2019-08-22  4:15 UTC (permalink / raw)
  To: zhengbin; +Cc: Steve French, CIFS, yi.zhang

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] fs/cifs/cifsacl.c: remove set but not used variables 'rc'
@ 2019-08-22  4:17 zhengbin
  2019-08-22  4:15 ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: zhengbin @ 2019-08-22  4:17 UTC (permalink / raw)
  To: sfrench, linux-cifs; +Cc: yi.zhang, zhengbin13

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/cifs/cifsacl.c: remove set but not used variables 'rc'
  2019-08-22  4:15 ` Steve French
@ 2019-09-09 17:30   ` Pavel Shilovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Shilovsky @ 2019-09-09 17:30 UTC (permalink / raw)
  To: Steve French; +Cc: zhengbin, Steve French, CIFS, yi.zhang

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22  4:17 [PATCH] fs/cifs/cifsacl.c: remove set but not used variables 'rc' zhengbin
2019-08-22  4:15 ` Steve French
2019-09-09 17:30   ` Pavel Shilovsky

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org linux-cifs@archiver.kernel.org
	public-inbox-index linux-cifs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox