LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] CIFS: Remove pointless variable assignment in cifs_dfs_do_automount()
@ 2011-01-22 20:07 Jesper Juhl
  2011-01-24  4:31 ` Steve French
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2011-01-22 20:07 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, samba-technical, linux-kernel

In fs/cifs/cifs_dfs_ref.c::cifs_dfs_do_automount() we have this code:

	...
	mnt = ERR_PTR(-EINVAL);
	if (IS_ERR(tlink)) {
		mnt = ERR_CAST(tlink);
		goto free_full_path;
	}
	ses = tlink_tcon(tlink)->ses;

	rc = get_dfs_path(xid, ses, full_path + 1, cifs_sb->local_nls,
		&num_referrals, &referrals,
		cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);

	cifs_put_tlink(tlink);

	mnt = ERR_PTR(-ENOENT);
	...

The assignment of 'mnt = ERR_PTR(-EINVAL);' is completely pointless. If we 
take the 'if (IS_ERR(tlink))' branch we'll set 'mnt' again and we'll also 
do so if we do not take the branch. There is no way we'll ever use 'mnt' 
with the assigned 'ERR_PTR(-EINVAL)' value, so we may as well just remove 
the pointless assignment.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 cifs_dfs_ref.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 7ed3653..f1c6862 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -297,7 +297,6 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
 
 	cifs_sb = CIFS_SB(mntpt->d_inode->i_sb);
 	tlink = cifs_sb_tlink(cifs_sb);
-	mnt = ERR_PTR(-EINVAL);
 	if (IS_ERR(tlink)) {
 		mnt = ERR_CAST(tlink);
 		goto free_full_path;


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] CIFS: Remove pointless variable assignment in cifs_dfs_do_automount()
  2011-01-22 20:07 [PATCH] CIFS: Remove pointless variable assignment in cifs_dfs_do_automount() Jesper Juhl
@ 2011-01-24  4:31 ` Steve French
  0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2011-01-24  4:31 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-cifs, Steve French, samba-technical, linux-kernel

merged - thx

On Sat, Jan 22, 2011 at 2:07 PM, Jesper Juhl <jj@chaosbits.net> wrote:
> In fs/cifs/cifs_dfs_ref.c::cifs_dfs_do_automount() we have this code:
>
>        ...
>        mnt = ERR_PTR(-EINVAL);
>        if (IS_ERR(tlink)) {
>                mnt = ERR_CAST(tlink);
>                goto free_full_path;
>        }
>        ses = tlink_tcon(tlink)->ses;
>
>        rc = get_dfs_path(xid, ses, full_path + 1, cifs_sb->local_nls,
>                &num_referrals, &referrals,
>                cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
>
>        cifs_put_tlink(tlink);
>
>        mnt = ERR_PTR(-ENOENT);
>        ...
>
> The assignment of 'mnt = ERR_PTR(-EINVAL);' is completely pointless. If we
> take the 'if (IS_ERR(tlink))' branch we'll set 'mnt' again and we'll also
> do so if we do not take the branch. There is no way we'll ever use 'mnt'
> with the assigned 'ERR_PTR(-EINVAL)' value, so we may as well just remove
> the pointless assignment.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  cifs_dfs_ref.c |    1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
> index 7ed3653..f1c6862 100644
> --- a/fs/cifs/cifs_dfs_ref.c
> +++ b/fs/cifs/cifs_dfs_ref.c
> @@ -297,7 +297,6 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
>
>        cifs_sb = CIFS_SB(mntpt->d_inode->i_sb);
>        tlink = cifs_sb_tlink(cifs_sb);
> -       mnt = ERR_PTR(-EINVAL);
>        if (IS_ERR(tlink)) {
>                mnt = ERR_CAST(tlink);
>                goto free_full_path;
>
>
> --
> Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> Plain text mails only, please.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Thanks,

Steve

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

end of thread, other threads:[~2011-01-24  4:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-22 20:07 [PATCH] CIFS: Remove pointless variable assignment in cifs_dfs_do_automount() Jesper Juhl
2011-01-24  4:31 ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).