2023-12-04 12:30:22

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH] nfsd: remove unnecessary NULL check

We check "state" for NULL on the previous line so it can't be NULL here.
No need to check again.

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Dan Carpenter <[email protected]>
---
fs/nfsd/nfs4state.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 40415929e2ae..fb551a3db1dc 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -6639,7 +6639,7 @@ __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
spin_unlock(&nn->s2s_cp_lock);
if (!state)
return nfserr_bad_stateid;
- if (!clp && state)
+ if (!clp)
*cps = state;
return 0;
}
--
2.42.0



2023-12-04 13:10:13

by Jeff Layton

[permalink] [raw]
Subject: Re: [PATCH] nfsd: remove unnecessary NULL check

On Mon, 2023-12-04 at 15:30 +0300, Dan Carpenter wrote:
> We check "state" for NULL on the previous line so it can't be NULL here.
> No need to check again.
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/r/[email protected]/
> Signed-off-by: Dan Carpenter <[email protected]>
> ---
> fs/nfsd/nfs4state.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 40415929e2ae..fb551a3db1dc 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -6639,7 +6639,7 @@ __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
> spin_unlock(&nn->s2s_cp_lock);
> if (!state)
> return nfserr_bad_stateid;
> - if (!clp && state)
> + if (!clp)
> *cps = state;
> return 0;
> }

Reviewed-by: Jeff Layton <[email protected]>

2023-12-04 14:43:25

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH] nfsd: remove unnecessary NULL check

On Mon, Dec 04, 2023 at 03:30:06PM +0300, Dan Carpenter wrote:
> We check "state" for NULL on the previous line so it can't be NULL here.
> No need to check again.
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/r/[email protected]/
> Signed-off-by: Dan Carpenter <[email protected]>

LGTM. Applied to nfsd-next for v6.8.


> ---
> fs/nfsd/nfs4state.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 40415929e2ae..fb551a3db1dc 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -6639,7 +6639,7 @@ __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
> spin_unlock(&nn->s2s_cp_lock);
> if (!state)
> return nfserr_bad_stateid;
> - if (!clp && state)
> + if (!clp)
> *cps = state;
> return 0;
> }
> --
> 2.42.0
>

--
Chuck Lever