* [PATCH 0/2] lockd: Adjustments for some function implementations @ 2017-08-17 14:32 ` SF Markus Elfring 0 siblings, 0 replies; 11+ messages in thread From: SF Markus Elfring @ 2017-08-17 14:32 UTC (permalink / raw) To: linux-nfs, Anna Schumaker, Benjamin Coddington, Christoph Hellwig, Colin Ian King, J. Bruce Fields, Jeff Layton, Trond Myklebust Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 17 Aug 2017 16:17:18 +0200 Two update suggestions were taken into account from static source code analysis. Markus Elfring (2): Delete an error message for a failed memory allocation in reclaimer() Adjust 61 checks for null pointers fs/lockd/clnt4xdr.c | 12 ++++++------ fs/lockd/clntlock.c | 16 ++++++---------- fs/lockd/clntproc.c | 12 ++++++------ fs/lockd/clntxdr.c | 12 ++++++------ fs/lockd/host.c | 22 +++++++++++----------- fs/lockd/mon.c | 16 ++++++++-------- fs/lockd/svc.c | 4 ++-- fs/lockd/svc4proc.c | 6 +++--- fs/lockd/svclock.c | 14 +++++++------- fs/lockd/svcproc.c | 6 +++--- fs/lockd/svcshare.c | 2 +- fs/lockd/svcsubs.c | 3 +-- 12 files changed, 60 insertions(+), 65 deletions(-) -- 2.14.0 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 0/2] lockd: Adjustments for some function implementations @ 2017-08-17 14:32 ` SF Markus Elfring 0 siblings, 0 replies; 11+ messages in thread From: SF Markus Elfring @ 2017-08-17 14:32 UTC (permalink / raw) To: linux-nfs, Anna Schumaker, Benjamin Coddington, Christoph Hellwig, Colin Ian King, J. Bruce Fields, Jeff Layton, Trond Myklebust Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 17 Aug 2017 16:17:18 +0200 Two update suggestions were taken into account from static source code analysis. Markus Elfring (2): Delete an error message for a failed memory allocation in reclaimer() Adjust 61 checks for null pointers fs/lockd/clnt4xdr.c | 12 ++++++------ fs/lockd/clntlock.c | 16 ++++++---------- fs/lockd/clntproc.c | 12 ++++++------ fs/lockd/clntxdr.c | 12 ++++++------ fs/lockd/host.c | 22 +++++++++++----------- fs/lockd/mon.c | 16 ++++++++-------- fs/lockd/svc.c | 4 ++-- fs/lockd/svc4proc.c | 6 +++--- fs/lockd/svclock.c | 14 +++++++------- fs/lockd/svcproc.c | 6 +++--- fs/lockd/svcshare.c | 2 +- fs/lockd/svcsubs.c | 3 +-- 12 files changed, 60 insertions(+), 65 deletions(-) -- 2.14.0 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/2] lockd: Delete an error message for a failed memory allocation in reclaimer() 2017-08-17 14:32 ` SF Markus Elfring @ 2017-08-17 14:33 ` SF Markus Elfring -1 siblings, 0 replies; 11+ messages in thread From: SF Markus Elfring @ 2017-08-17 14:33 UTC (permalink / raw) To: linux-nfs, Anna Schumaker, Benjamin Coddington, Christoph Hellwig, Colin Ian King, J. Bruce Fields, Jeff Layton, Trond Myklebust Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Wed, 16 Aug 2017 22:35:24 +0200 Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- fs/lockd/clntlock.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 27d577dbe51a..96c1d14c18f1 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c @@ -235,12 +235,8 @@ reclaimer(void *ptr) struct net *net = host->net; req = kmalloc(sizeof(*req), GFP_KERNEL); - if (!req) { - printk(KERN_ERR "lockd: reclaimer unable to alloc memory." - " Locks for %s won't be reclaimed!\n", - host->h_name); + if (!req) return 0; - } allow_signal(SIGKILL); -- 2.14.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 1/2] lockd: Delete an error message for a failed memory allocation in reclaimer() @ 2017-08-17 14:33 ` SF Markus Elfring 0 siblings, 0 replies; 11+ messages in thread From: SF Markus Elfring @ 2017-08-17 14:33 UTC (permalink / raw) To: linux-nfs, Anna Schumaker, Benjamin Coddington, Christoph Hellwig, Colin Ian King, J. Bruce Fields, Jeff Layton, Trond Myklebust Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Wed, 16 Aug 2017 22:35:24 +0200 Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- fs/lockd/clntlock.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 27d577dbe51a..96c1d14c18f1 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c @@ -235,12 +235,8 @@ reclaimer(void *ptr) struct net *net = host->net; req = kmalloc(sizeof(*req), GFP_KERNEL); - if (!req) { - printk(KERN_ERR "lockd: reclaimer unable to alloc memory." - " Locks for %s won't be reclaimed!\n", - host->h_name); + if (!req) return 0; - } allow_signal(SIGKILL); -- 2.14.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/2] lockd: Adjust 61 checks for null pointers 2017-08-17 14:32 ` SF Markus Elfring @ 2017-08-17 14:34 ` SF Markus Elfring -1 siblings, 0 replies; 11+ messages in thread From: SF Markus Elfring @ 2017-08-17 14:34 UTC (permalink / raw) To: linux-nfs, Anna Schumaker, Benjamin Coddington, Christoph Hellwig, Colin Ian King, J. Bruce Fields, Jeff Layton, Trond Myklebust Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 17 Aug 2017 16:00:18 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix the affected source code places. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- fs/lockd/clnt4xdr.c | 12 ++++++------ fs/lockd/clntlock.c | 10 +++++----- fs/lockd/clntproc.c | 12 ++++++------ fs/lockd/clntxdr.c | 12 ++++++------ fs/lockd/host.c | 22 +++++++++++----------- fs/lockd/mon.c | 16 ++++++++-------- fs/lockd/svc.c | 4 ++-- fs/lockd/svc4proc.c | 6 +++--- fs/lockd/svclock.c | 14 +++++++------- fs/lockd/svcproc.c | 6 +++--- fs/lockd/svcshare.c | 2 +- fs/lockd/svcsubs.c | 3 +-- 12 files changed, 59 insertions(+), 60 deletions(-) diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c index c349fc0f9b80..ec6473d194fd 100644 --- a/fs/lockd/clnt4xdr.c +++ b/fs/lockd/clnt4xdr.c @@ -131,7 +131,7 @@ static int decode_netobj(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); if (unlikely(length > XDR_MAX_NETOBJ)) @@ -163,7 +163,7 @@ static int decode_cookie(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); /* apparently HPUX can return empty cookies */ @@ -172,7 +172,7 @@ static int decode_cookie(struct xdr_stream *xdr, if (length > NLM_MAXCOOKIELEN) goto out_size; p = xdr_inline_decode(xdr, length); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; cookie->len = length; memcpy(cookie->data, p, length); @@ -234,7 +234,7 @@ static int decode_nlm4_stat(struct xdr_stream *xdr, __be32 *stat) __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; if (unlikely(ntohl(*p) > ntohl(nlm4_failed))) goto out_bad_xdr; @@ -289,7 +289,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) locks_init_lock(fl); p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; exclusive = be32_to_cpup(p++); lock->svid = be32_to_cpup(p); @@ -300,7 +300,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) goto out; p = xdr_inline_decode(xdr, 8 + 8); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; fl->fl_flags = FL_POSIX; diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 96c1d14c18f1..ef0cff53dc83 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c @@ -64,9 +64,9 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init) nlm_init->protocol, nlm_version, nlm_init->hostname, nlm_init->noresvport, nlm_init->net); - if (host = NULL) + if (!host) goto out_nohost; - if (host->h_rpcclnt = NULL && nlm_bind_host(host) = NULL) + if (!host->h_rpcclnt && !nlm_bind_host(host)) goto out_nobind; host->h_nlmclnt_ops = nlm_init->nlmclnt_ops; @@ -101,7 +101,7 @@ struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock * struct nlm_wait *block; block = kmalloc(sizeof(*block), GFP_KERNEL); - if (block != NULL) { + if (block) { block->b_host = host; block->b_lock = fl; init_waitqueue_head(&block->b_wait); @@ -116,7 +116,7 @@ struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock * void nlmclnt_finish_block(struct nlm_wait *block) { - if (block = NULL) + if (!block) return; spin_lock(&nlm_blocked_lock); list_del(&block->b_list); @@ -134,7 +134,7 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout) /* A borken server might ask us to block even if we didn't * request it. Just say no! */ - if (block = NULL) + if (!block) return -EAGAIN; /* Go to sleep waiting for GRANT callback. Some servers seem diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 066ac313ae5c..d632d1aa6452 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -98,12 +98,12 @@ static struct nlm_lockowner *nlm_find_lockowner(struct nlm_host *host, fl_owner_ spin_lock(&host->h_lock); res = __nlm_find_lockowner(host, owner); - if (res = NULL) { + if (!res) { spin_unlock(&host->h_lock); new = kmalloc(sizeof(*new), GFP_KERNEL); spin_lock(&host->h_lock); res = __nlm_find_lockowner(host, owner); - if (res = NULL && new != NULL) { + if (!res && new) { res = new; atomic_set(&new->count, 1); new->owner = owner; @@ -142,7 +142,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) static void nlmclnt_release_lockargs(struct nlm_rqst *req) { - WARN_ON_ONCE(req->a_args.lock.fl.fl_ops != NULL); + WARN_ON_ONCE(req->a_args.lock.fl.fl_ops); } /** @@ -160,7 +160,7 @@ int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *dat const struct nlmclnt_operations *nlmclnt_ops = host->h_nlmclnt_ops; call = nlm_alloc_call(host); - if (call = NULL) + if (!call) return -ENOMEM; if (nlmclnt_ops && nlmclnt_ops->nlmclnt_alloc_call) @@ -203,7 +203,7 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host) for(;;) { call = kzalloc(sizeof(*call), GFP_KERNEL); - if (call != NULL) { + if (call) { atomic_set(&call->a_count, 1); locks_init_lock(&call->a_args.lock.fl); locks_init_lock(&call->a_res.lock.fl); @@ -350,7 +350,7 @@ static struct rpc_task *__nlm_async_call(struct nlm_rqst *req, u32 proc, struct /* If we have no RPC client yet, create one. */ clnt = nlm_bind_host(host); - if (clnt = NULL) + if (!clnt) goto out_err; msg->rpc_proc = &clnt->cl_procinfo[proc]; task_setup_data.rpc_client = clnt; diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c index 3b4724a6c4ee..e05124b7897c 100644 --- a/fs/lockd/clntxdr.c +++ b/fs/lockd/clntxdr.c @@ -128,7 +128,7 @@ static int decode_netobj(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); if (unlikely(length > XDR_MAX_NETOBJ)) @@ -160,7 +160,7 @@ static int decode_cookie(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); /* apparently HPUX can return empty cookies */ @@ -169,7 +169,7 @@ static int decode_cookie(struct xdr_stream *xdr, if (length > NLM_MAXCOOKIELEN) goto out_size; p = xdr_inline_decode(xdr, length); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; cookie->len = length; memcpy(cookie->data, p, length); @@ -229,7 +229,7 @@ static int decode_nlm_stat(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; if (unlikely(ntohl(*p) > ntohl(nlm_lck_denied_grace_period))) goto out_enum; @@ -283,7 +283,7 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) locks_init_lock(fl); p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; exclusive = be32_to_cpup(p++); lock->svid = be32_to_cpup(p); @@ -294,7 +294,7 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) goto out; p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) goto out_overflow; fl->fl_flags = FL_POSIX; diff --git a/fs/lockd/host.c b/fs/lockd/host.c index d716c9993a26..1aea490ba19a 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -112,13 +112,13 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni, struct nlm_host *host = NULL; unsigned long now = jiffies; - if (nsm != NULL) + if (nsm) atomic_inc(&nsm->sm_count); else { host = NULL; nsm = nsm_get_handle(ni->net, ni->sap, ni->salen, ni->hostname, ni->hostname_len); - if (unlikely(nsm = NULL)) { + if (unlikely(!nsm)) { dprintk("lockd: %s failed; no nsm handle\n", __func__); goto out; @@ -126,7 +126,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni, } host = kmalloc(sizeof(*host), GFP_KERNEL); - if (unlikely(host = NULL)) { + if (unlikely(!host)) { dprintk("lockd: %s failed; no memory\n", __func__); nsm_release(nsm); goto out; @@ -185,7 +185,7 @@ static void nlm_destroy_host_locked(struct nlm_host *host) nsm_release(host->h_nsmhandle); clnt = host->h_rpcclnt; - if (clnt != NULL) + if (clnt) rpc_shutdown_client(clnt); kfree(host); @@ -245,7 +245,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, continue; /* Same address. Share an NSM handle if we already have one */ - if (nsm = NULL) + if (!nsm) nsm = host->h_nsmhandle; if (host->h_proto != protocol) @@ -260,7 +260,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, } host = nlm_alloc_host(&ni, nsm); - if (unlikely(host = NULL)) + if (unlikely(!host)) goto out; hlist_add_head(&host->h_hash, chain); @@ -282,7 +282,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, */ void nlmclnt_release_host(struct nlm_host *host) { - if (host = NULL) + if (!host) return; dprintk("lockd: release client host %s\n", host->h_name); @@ -357,7 +357,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, continue; /* Same address. Share an NSM handle if we already have one */ - if (nsm = NULL) + if (!nsm) nsm = host->h_nsmhandle; if (host->h_proto != ni.protocol) @@ -378,7 +378,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, } host = nlm_alloc_host(&ni, nsm); - if (unlikely(host = NULL)) + if (unlikely(!host)) goto out; memcpy(nlm_srcaddr(host), src_sap, src_len); @@ -403,7 +403,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, */ void nlmsvc_release_host(struct nlm_host *host) { - if (host = NULL) + if (!host) return; dprintk("lockd: release server host %s\n", host->h_name); @@ -547,7 +547,7 @@ void nlm_host_rebooted(const struct net *net, const struct nlm_reboot *info) struct nlm_host *host; nsm = nsm_reboot_lookup(net, info); - if (unlikely(nsm = NULL)) + if (unlikely(!nsm)) return; /* Mark all hosts tied to this NSM state as having rebooted. diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 9d8166c39c54..3aa95a7ed4a0 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c @@ -274,7 +274,7 @@ static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap, struct nsm_handle *new; new = kzalloc(sizeof(*new) + hostname_len + 1, GFP_KERNEL); - if (unlikely(new = NULL)) + if (unlikely(!new)) return NULL; atomic_set(&new->sm_count, 1); @@ -328,13 +328,13 @@ struct nsm_handle *nsm_get_handle(const struct net *net, retry: spin_lock(&nsm_lock); - if (nsm_use_hostnames && hostname != NULL) + if (nsm_use_hostnames && hostname) cached = nsm_lookup_hostname(&ln->nsm_handles, hostname, hostname_len); else cached = nsm_lookup_addr(&ln->nsm_handles, sap); - if (cached != NULL) { + if (cached) { atomic_inc(&cached->sm_count); spin_unlock(&nsm_lock); kfree(new); @@ -345,7 +345,7 @@ struct nsm_handle *nsm_get_handle(const struct net *net, return cached; } - if (new != NULL) { + if (new) { list_add(&new->sm_link, &ln->nsm_handles); spin_unlock(&nsm_lock); dprintk("lockd: created nsm_handle for %s (%s)\n", @@ -356,7 +356,7 @@ struct nsm_handle *nsm_get_handle(const struct net *net, spin_unlock(&nsm_lock); new = nsm_create_handle(sap, salen, hostname, hostname_len); - if (unlikely(new = NULL)) + if (unlikely(!new)) return NULL; goto retry; } @@ -379,7 +379,7 @@ struct nsm_handle *nsm_reboot_lookup(const struct net *net, spin_lock(&nsm_lock); cached = nsm_lookup_priv(&ln->nsm_handles, &info->priv); - if (unlikely(cached = NULL)) { + if (unlikely(!cached)) { spin_unlock(&nsm_lock); dprintk("lockd: never saw rebooted peer '%.*s' before\n", info->len, info->mon); @@ -496,7 +496,7 @@ static int nsm_xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p; p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) return -EIO; resp->status = be32_to_cpup(p++); resp->state = be32_to_cpup(p); @@ -514,7 +514,7 @@ static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p = NULL)) + if (unlikely(!p)) return -EIO; resp->state = be32_to_cpup(p); diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 726b6cecf430..8a5d894a4f07 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -190,7 +190,7 @@ static int create_lockd_listener(struct svc_serv *serv, const char *name, struct svc_xprt *xprt; xprt = svc_find_xprt(serv, name, net, family, 0); - if (xprt = NULL) + if (!xprt) return svc_create_xprt(serv, name, net, family, port, SVC_SOCK_DEFAULTS); svc_xprt_put(xprt); @@ -699,7 +699,7 @@ static int __init init_nlm(void) #ifdef CONFIG_SYSCTL err = -ENOMEM; nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root); - if (nlm_sysctl_table = NULL) + if (!nlm_sysctl_table) goto err_sysctl; #endif err = register_pernet_subsys(&lockd_net_ops); diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 82925f17ec45..b16bdd33e5b8 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -38,7 +38,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, *hostp = host; /* Obtain file pointer. Not used by FREE_ALL call. */ - if (filp != NULL) { + if (filp) { if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0) goto no_locks; *filp = file; @@ -285,12 +285,12 @@ static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, host = nlmsvc_lookup_host(rqstp, argp->lock.caller, argp->lock.len); - if (host = NULL) + if (!host) return rpc_system_err; call = nlm_alloc_call(host); nlmsvc_release_host(host); - if (call = NULL) + if (!call) return rpc_system_err; stat = func(rqstp, &call->a_res); diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 3507c80d1d4b..8f1c058f16b3 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -220,12 +220,12 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host, struct nlm_rqst *call = NULL; call = nlm_alloc_call(host); - if (call = NULL) + if (!call) return NULL; /* Allocate memory for block, and initialize arguments */ block = kzalloc(sizeof(*block), GFP_KERNEL); - if (block = NULL) + if (!block) goto failed; kref_init(&block->b_count); INIT_LIST_HEAD(&block->b_list); @@ -299,7 +299,7 @@ static void nlmsvc_free_block(struct kref *kref) static void nlmsvc_release_block(struct nlm_block *block) { - if (block != NULL) + if (block) kref_put_mutex(&block->b_count, nlmsvc_free_block, &block->b_file->f_mutex); } @@ -381,7 +381,7 @@ nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block) if (rqstp->rq_chandle.defer) { block->b_deferred_req rqstp->rq_chandle.defer(block->b_cache_req); - if (block->b_deferred_req != NULL) + if (block->b_deferred_req) status = nlm_drop_reply; } dprintk("lockd: nlmsvc_defer_lock_rqst block %p flags %d status %d\n", @@ -417,10 +417,10 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, * or create new block */ block = nlmsvc_lookup_block(file, lock); - if (block = NULL) { + if (!block) { block = nlmsvc_create_block(rqstp, host, file, lock, cookie); ret = nlm_lck_denied_nolocks; - if (block = NULL) + if (!block) goto out; lock = &block->b_call->a_args.lock; } else @@ -606,7 +606,7 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l mutex_lock(&file->f_mutex); block = nlmsvc_lookup_block(file, lock); mutex_unlock(&file->f_mutex); - if (block != NULL) { + if (block) { vfs_cancel_lock(block->b_file->f_file, &block->b_call->a_args.lock.fl); status = nlmsvc_unlink_block(block); diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 07915162581d..548f732c8f8e 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -67,7 +67,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, *hostp = host; /* Obtain file pointer. Not used by FREE_ALL call. */ - if (filp != NULL) { + if (filp) { error = cast_status(nlm_lookup_file(rqstp, &file, &lock->fh)); if (error != 0) goto no_locks; @@ -326,12 +326,12 @@ static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, host = nlmsvc_lookup_host(rqstp, argp->lock.caller, argp->lock.len); - if (host = NULL) + if (!host) return rpc_system_err; call = nlm_alloc_call(host); nlmsvc_release_host(host); - if (call = NULL) + if (!call) return rpc_system_err; stat = func(rqstp, &call->a_res); diff --git a/fs/lockd/svcshare.c b/fs/lockd/svcshare.c index b0ae07008700..84b54efee9b6 100644 --- a/fs/lockd/svcshare.c +++ b/fs/lockd/svcshare.c @@ -41,7 +41,7 @@ nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file, share = kmalloc(sizeof(*share) + oh->len, GFP_KERNEL); - if (share = NULL) + if (!share) return nlm_lck_denied_nolocks; /* Copy owner handle */ diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index a563ddbc19e6..507b4c3ff103 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -331,8 +331,7 @@ nlmsvc_mark_host(void *data, struct nlm_host *hint) { struct nlm_host *host = data; - if ((hint->net = NULL) || - (host->net = hint->net)) + if (!hint->net || host->net = hint->net) host->h_inuse = 1; return 0; } -- 2.14.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/2] lockd: Adjust 61 checks for null pointers @ 2017-08-17 14:34 ` SF Markus Elfring 0 siblings, 0 replies; 11+ messages in thread From: SF Markus Elfring @ 2017-08-17 14:34 UTC (permalink / raw) To: linux-nfs, Anna Schumaker, Benjamin Coddington, Christoph Hellwig, Colin Ian King, J. Bruce Fields, Jeff Layton, Trond Myklebust Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 17 Aug 2017 16:00:18 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix the affected source code places. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- fs/lockd/clnt4xdr.c | 12 ++++++------ fs/lockd/clntlock.c | 10 +++++----- fs/lockd/clntproc.c | 12 ++++++------ fs/lockd/clntxdr.c | 12 ++++++------ fs/lockd/host.c | 22 +++++++++++----------- fs/lockd/mon.c | 16 ++++++++-------- fs/lockd/svc.c | 4 ++-- fs/lockd/svc4proc.c | 6 +++--- fs/lockd/svclock.c | 14 +++++++------- fs/lockd/svcproc.c | 6 +++--- fs/lockd/svcshare.c | 2 +- fs/lockd/svcsubs.c | 3 +-- 12 files changed, 59 insertions(+), 60 deletions(-) diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c index c349fc0f9b80..ec6473d194fd 100644 --- a/fs/lockd/clnt4xdr.c +++ b/fs/lockd/clnt4xdr.c @@ -131,7 +131,7 @@ static int decode_netobj(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); if (unlikely(length > XDR_MAX_NETOBJ)) @@ -163,7 +163,7 @@ static int decode_cookie(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); /* apparently HPUX can return empty cookies */ @@ -172,7 +172,7 @@ static int decode_cookie(struct xdr_stream *xdr, if (length > NLM_MAXCOOKIELEN) goto out_size; p = xdr_inline_decode(xdr, length); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; cookie->len = length; memcpy(cookie->data, p, length); @@ -234,7 +234,7 @@ static int decode_nlm4_stat(struct xdr_stream *xdr, __be32 *stat) __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; if (unlikely(ntohl(*p) > ntohl(nlm4_failed))) goto out_bad_xdr; @@ -289,7 +289,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) locks_init_lock(fl); p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; exclusive = be32_to_cpup(p++); lock->svid = be32_to_cpup(p); @@ -300,7 +300,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) goto out; p = xdr_inline_decode(xdr, 8 + 8); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; fl->fl_flags = FL_POSIX; diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 96c1d14c18f1..ef0cff53dc83 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c @@ -64,9 +64,9 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init) nlm_init->protocol, nlm_version, nlm_init->hostname, nlm_init->noresvport, nlm_init->net); - if (host == NULL) + if (!host) goto out_nohost; - if (host->h_rpcclnt == NULL && nlm_bind_host(host) == NULL) + if (!host->h_rpcclnt && !nlm_bind_host(host)) goto out_nobind; host->h_nlmclnt_ops = nlm_init->nlmclnt_ops; @@ -101,7 +101,7 @@ struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock * struct nlm_wait *block; block = kmalloc(sizeof(*block), GFP_KERNEL); - if (block != NULL) { + if (block) { block->b_host = host; block->b_lock = fl; init_waitqueue_head(&block->b_wait); @@ -116,7 +116,7 @@ struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock * void nlmclnt_finish_block(struct nlm_wait *block) { - if (block == NULL) + if (!block) return; spin_lock(&nlm_blocked_lock); list_del(&block->b_list); @@ -134,7 +134,7 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout) /* A borken server might ask us to block even if we didn't * request it. Just say no! */ - if (block == NULL) + if (!block) return -EAGAIN; /* Go to sleep waiting for GRANT callback. Some servers seem diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 066ac313ae5c..d632d1aa6452 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -98,12 +98,12 @@ static struct nlm_lockowner *nlm_find_lockowner(struct nlm_host *host, fl_owner_ spin_lock(&host->h_lock); res = __nlm_find_lockowner(host, owner); - if (res == NULL) { + if (!res) { spin_unlock(&host->h_lock); new = kmalloc(sizeof(*new), GFP_KERNEL); spin_lock(&host->h_lock); res = __nlm_find_lockowner(host, owner); - if (res == NULL && new != NULL) { + if (!res && new) { res = new; atomic_set(&new->count, 1); new->owner = owner; @@ -142,7 +142,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) static void nlmclnt_release_lockargs(struct nlm_rqst *req) { - WARN_ON_ONCE(req->a_args.lock.fl.fl_ops != NULL); + WARN_ON_ONCE(req->a_args.lock.fl.fl_ops); } /** @@ -160,7 +160,7 @@ int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *dat const struct nlmclnt_operations *nlmclnt_ops = host->h_nlmclnt_ops; call = nlm_alloc_call(host); - if (call == NULL) + if (!call) return -ENOMEM; if (nlmclnt_ops && nlmclnt_ops->nlmclnt_alloc_call) @@ -203,7 +203,7 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host) for(;;) { call = kzalloc(sizeof(*call), GFP_KERNEL); - if (call != NULL) { + if (call) { atomic_set(&call->a_count, 1); locks_init_lock(&call->a_args.lock.fl); locks_init_lock(&call->a_res.lock.fl); @@ -350,7 +350,7 @@ static struct rpc_task *__nlm_async_call(struct nlm_rqst *req, u32 proc, struct /* If we have no RPC client yet, create one. */ clnt = nlm_bind_host(host); - if (clnt == NULL) + if (!clnt) goto out_err; msg->rpc_proc = &clnt->cl_procinfo[proc]; task_setup_data.rpc_client = clnt; diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c index 3b4724a6c4ee..e05124b7897c 100644 --- a/fs/lockd/clntxdr.c +++ b/fs/lockd/clntxdr.c @@ -128,7 +128,7 @@ static int decode_netobj(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); if (unlikely(length > XDR_MAX_NETOBJ)) @@ -160,7 +160,7 @@ static int decode_cookie(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; length = be32_to_cpup(p++); /* apparently HPUX can return empty cookies */ @@ -169,7 +169,7 @@ static int decode_cookie(struct xdr_stream *xdr, if (length > NLM_MAXCOOKIELEN) goto out_size; p = xdr_inline_decode(xdr, length); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; cookie->len = length; memcpy(cookie->data, p, length); @@ -229,7 +229,7 @@ static int decode_nlm_stat(struct xdr_stream *xdr, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; if (unlikely(ntohl(*p) > ntohl(nlm_lck_denied_grace_period))) goto out_enum; @@ -283,7 +283,7 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) locks_init_lock(fl); p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; exclusive = be32_to_cpup(p++); lock->svid = be32_to_cpup(p); @@ -294,7 +294,7 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) goto out; p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) goto out_overflow; fl->fl_flags = FL_POSIX; diff --git a/fs/lockd/host.c b/fs/lockd/host.c index d716c9993a26..1aea490ba19a 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -112,13 +112,13 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni, struct nlm_host *host = NULL; unsigned long now = jiffies; - if (nsm != NULL) + if (nsm) atomic_inc(&nsm->sm_count); else { host = NULL; nsm = nsm_get_handle(ni->net, ni->sap, ni->salen, ni->hostname, ni->hostname_len); - if (unlikely(nsm == NULL)) { + if (unlikely(!nsm)) { dprintk("lockd: %s failed; no nsm handle\n", __func__); goto out; @@ -126,7 +126,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni, } host = kmalloc(sizeof(*host), GFP_KERNEL); - if (unlikely(host == NULL)) { + if (unlikely(!host)) { dprintk("lockd: %s failed; no memory\n", __func__); nsm_release(nsm); goto out; @@ -185,7 +185,7 @@ static void nlm_destroy_host_locked(struct nlm_host *host) nsm_release(host->h_nsmhandle); clnt = host->h_rpcclnt; - if (clnt != NULL) + if (clnt) rpc_shutdown_client(clnt); kfree(host); @@ -245,7 +245,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, continue; /* Same address. Share an NSM handle if we already have one */ - if (nsm == NULL) + if (!nsm) nsm = host->h_nsmhandle; if (host->h_proto != protocol) @@ -260,7 +260,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, } host = nlm_alloc_host(&ni, nsm); - if (unlikely(host == NULL)) + if (unlikely(!host)) goto out; hlist_add_head(&host->h_hash, chain); @@ -282,7 +282,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, */ void nlmclnt_release_host(struct nlm_host *host) { - if (host == NULL) + if (!host) return; dprintk("lockd: release client host %s\n", host->h_name); @@ -357,7 +357,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, continue; /* Same address. Share an NSM handle if we already have one */ - if (nsm == NULL) + if (!nsm) nsm = host->h_nsmhandle; if (host->h_proto != ni.protocol) @@ -378,7 +378,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, } host = nlm_alloc_host(&ni, nsm); - if (unlikely(host == NULL)) + if (unlikely(!host)) goto out; memcpy(nlm_srcaddr(host), src_sap, src_len); @@ -403,7 +403,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, */ void nlmsvc_release_host(struct nlm_host *host) { - if (host == NULL) + if (!host) return; dprintk("lockd: release server host %s\n", host->h_name); @@ -547,7 +547,7 @@ void nlm_host_rebooted(const struct net *net, const struct nlm_reboot *info) struct nlm_host *host; nsm = nsm_reboot_lookup(net, info); - if (unlikely(nsm == NULL)) + if (unlikely(!nsm)) return; /* Mark all hosts tied to this NSM state as having rebooted. diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 9d8166c39c54..3aa95a7ed4a0 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c @@ -274,7 +274,7 @@ static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap, struct nsm_handle *new; new = kzalloc(sizeof(*new) + hostname_len + 1, GFP_KERNEL); - if (unlikely(new == NULL)) + if (unlikely(!new)) return NULL; atomic_set(&new->sm_count, 1); @@ -328,13 +328,13 @@ struct nsm_handle *nsm_get_handle(const struct net *net, retry: spin_lock(&nsm_lock); - if (nsm_use_hostnames && hostname != NULL) + if (nsm_use_hostnames && hostname) cached = nsm_lookup_hostname(&ln->nsm_handles, hostname, hostname_len); else cached = nsm_lookup_addr(&ln->nsm_handles, sap); - if (cached != NULL) { + if (cached) { atomic_inc(&cached->sm_count); spin_unlock(&nsm_lock); kfree(new); @@ -345,7 +345,7 @@ struct nsm_handle *nsm_get_handle(const struct net *net, return cached; } - if (new != NULL) { + if (new) { list_add(&new->sm_link, &ln->nsm_handles); spin_unlock(&nsm_lock); dprintk("lockd: created nsm_handle for %s (%s)\n", @@ -356,7 +356,7 @@ struct nsm_handle *nsm_get_handle(const struct net *net, spin_unlock(&nsm_lock); new = nsm_create_handle(sap, salen, hostname, hostname_len); - if (unlikely(new == NULL)) + if (unlikely(!new)) return NULL; goto retry; } @@ -379,7 +379,7 @@ struct nsm_handle *nsm_reboot_lookup(const struct net *net, spin_lock(&nsm_lock); cached = nsm_lookup_priv(&ln->nsm_handles, &info->priv); - if (unlikely(cached == NULL)) { + if (unlikely(!cached)) { spin_unlock(&nsm_lock); dprintk("lockd: never saw rebooted peer '%.*s' before\n", info->len, info->mon); @@ -496,7 +496,7 @@ static int nsm_xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p; p = xdr_inline_decode(xdr, 4 + 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) return -EIO; resp->status = be32_to_cpup(p++); resp->state = be32_to_cpup(p); @@ -514,7 +514,7 @@ static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p; p = xdr_inline_decode(xdr, 4); - if (unlikely(p == NULL)) + if (unlikely(!p)) return -EIO; resp->state = be32_to_cpup(p); diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 726b6cecf430..8a5d894a4f07 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -190,7 +190,7 @@ static int create_lockd_listener(struct svc_serv *serv, const char *name, struct svc_xprt *xprt; xprt = svc_find_xprt(serv, name, net, family, 0); - if (xprt == NULL) + if (!xprt) return svc_create_xprt(serv, name, net, family, port, SVC_SOCK_DEFAULTS); svc_xprt_put(xprt); @@ -699,7 +699,7 @@ static int __init init_nlm(void) #ifdef CONFIG_SYSCTL err = -ENOMEM; nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root); - if (nlm_sysctl_table == NULL) + if (!nlm_sysctl_table) goto err_sysctl; #endif err = register_pernet_subsys(&lockd_net_ops); diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 82925f17ec45..b16bdd33e5b8 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -38,7 +38,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, *hostp = host; /* Obtain file pointer. Not used by FREE_ALL call. */ - if (filp != NULL) { + if (filp) { if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0) goto no_locks; *filp = file; @@ -285,12 +285,12 @@ static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, host = nlmsvc_lookup_host(rqstp, argp->lock.caller, argp->lock.len); - if (host == NULL) + if (!host) return rpc_system_err; call = nlm_alloc_call(host); nlmsvc_release_host(host); - if (call == NULL) + if (!call) return rpc_system_err; stat = func(rqstp, &call->a_res); diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 3507c80d1d4b..8f1c058f16b3 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -220,12 +220,12 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host, struct nlm_rqst *call = NULL; call = nlm_alloc_call(host); - if (call == NULL) + if (!call) return NULL; /* Allocate memory for block, and initialize arguments */ block = kzalloc(sizeof(*block), GFP_KERNEL); - if (block == NULL) + if (!block) goto failed; kref_init(&block->b_count); INIT_LIST_HEAD(&block->b_list); @@ -299,7 +299,7 @@ static void nlmsvc_free_block(struct kref *kref) static void nlmsvc_release_block(struct nlm_block *block) { - if (block != NULL) + if (block) kref_put_mutex(&block->b_count, nlmsvc_free_block, &block->b_file->f_mutex); } @@ -381,7 +381,7 @@ nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block) if (rqstp->rq_chandle.defer) { block->b_deferred_req = rqstp->rq_chandle.defer(block->b_cache_req); - if (block->b_deferred_req != NULL) + if (block->b_deferred_req) status = nlm_drop_reply; } dprintk("lockd: nlmsvc_defer_lock_rqst block %p flags %d status %d\n", @@ -417,10 +417,10 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, * or create new block */ block = nlmsvc_lookup_block(file, lock); - if (block == NULL) { + if (!block) { block = nlmsvc_create_block(rqstp, host, file, lock, cookie); ret = nlm_lck_denied_nolocks; - if (block == NULL) + if (!block) goto out; lock = &block->b_call->a_args.lock; } else @@ -606,7 +606,7 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l mutex_lock(&file->f_mutex); block = nlmsvc_lookup_block(file, lock); mutex_unlock(&file->f_mutex); - if (block != NULL) { + if (block) { vfs_cancel_lock(block->b_file->f_file, &block->b_call->a_args.lock.fl); status = nlmsvc_unlink_block(block); diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 07915162581d..548f732c8f8e 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -67,7 +67,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, *hostp = host; /* Obtain file pointer. Not used by FREE_ALL call. */ - if (filp != NULL) { + if (filp) { error = cast_status(nlm_lookup_file(rqstp, &file, &lock->fh)); if (error != 0) goto no_locks; @@ -326,12 +326,12 @@ static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, host = nlmsvc_lookup_host(rqstp, argp->lock.caller, argp->lock.len); - if (host == NULL) + if (!host) return rpc_system_err; call = nlm_alloc_call(host); nlmsvc_release_host(host); - if (call == NULL) + if (!call) return rpc_system_err; stat = func(rqstp, &call->a_res); diff --git a/fs/lockd/svcshare.c b/fs/lockd/svcshare.c index b0ae07008700..84b54efee9b6 100644 --- a/fs/lockd/svcshare.c +++ b/fs/lockd/svcshare.c @@ -41,7 +41,7 @@ nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file, share = kmalloc(sizeof(*share) + oh->len, GFP_KERNEL); - if (share == NULL) + if (!share) return nlm_lck_denied_nolocks; /* Copy owner handle */ diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index a563ddbc19e6..507b4c3ff103 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -331,8 +331,7 @@ nlmsvc_mark_host(void *data, struct nlm_host *hint) { struct nlm_host *host = data; - if ((hint->net == NULL) || - (host->net == hint->net)) + if (!hint->net || host->net == hint->net) host->h_inuse = 1; return 0; } -- 2.14.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] lockd: Adjust 61 checks for null pointers 2017-08-17 14:34 ` SF Markus Elfring (?) @ 2017-08-18 15:53 ` Trond Myklebust -1 siblings, 0 replies; 11+ messages in thread From: Trond Myklebust @ 2017-08-18 15:53 UTC (permalink / raw) To: colin.king@canonical.com, bfields@fieldses.org, hch, linux-nfs@vger.kernel.org, jlayton@poochiereds.net, elfring@users.sourceforge.net, bcodding redhat, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org T24gVGh1LCAyMDE3LTA4LTE3IGF0IDE2OjM0ICswMjAwLCBTRiBNYXJrdXMgRWxmcmluZyB3cm90 ZToNCj4gRnJvbTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdAdXNlcnMuc291cmNlZm9yZ2UubmV0 Pg0KPiBEYXRlOiBUaHUsIDE3IEF1ZyAyMDE3IDE2OjAwOjE4ICswMjAwDQo+IE1JTUUtVmVyc2lv bjogMS4wDQo+IENvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOA0KPiBDb250 ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0DQo+IA0KPiBUaGUgc2NyaXB0IOKAnGNoZWNrcGF0 Y2gucGzigJ0gcG9pbnRlZCBpbmZvcm1hdGlvbiBvdXQgbGlrZSB0aGUNCj4gZm9sbG93aW5nLg0K PiANCj4gQ29tcGFyaXNvbiB0byBOVUxMIGNvdWxkIGJlIHdyaXR0ZW4g4oCmDQo+IA0KPiBUaHVz IGZpeCB0aGUgYWZmZWN0ZWQgc291cmNlIGNvZGUgcGxhY2VzLg0KPiANCj4gU2lnbmVkLW9mZi1i eTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdAdXNlcnMuc291cmNlZm9yZ2UubmV0Pg0KPiAtLS0N Cj4gIGZzL2xvY2tkL2NsbnQ0eGRyLmMgfCAxMiArKysrKystLS0tLS0NCj4gIGZzL2xvY2tkL2Ns bnRsb2NrLmMgfCAxMCArKysrKy0tLS0tDQo+ICBmcy9sb2NrZC9jbG50cHJvYy5jIHwgMTIgKysr KysrLS0tLS0tDQo+ICBmcy9sb2NrZC9jbG50eGRyLmMgIHwgMTIgKysrKysrLS0tLS0tDQo+ICBm cy9sb2NrZC9ob3N0LmMgICAgIHwgMjIgKysrKysrKysrKystLS0tLS0tLS0tLQ0KPiAgZnMvbG9j a2QvbW9uLmMgICAgICB8IDE2ICsrKysrKysrLS0tLS0tLS0NCj4gIGZzL2xvY2tkL3N2Yy5jICAg ICAgfCAgNCArKy0tDQo+ICBmcy9sb2NrZC9zdmM0cHJvYy5jIHwgIDYgKysrLS0tDQo+ICBmcy9s b2NrZC9zdmNsb2NrLmMgIHwgMTQgKysrKysrKy0tLS0tLS0NCj4gIGZzL2xvY2tkL3N2Y3Byb2Mu YyAgfCAgNiArKystLS0NCj4gIGZzL2xvY2tkL3N2Y3NoYXJlLmMgfCAgMiArLQ0KPiAgZnMvbG9j a2Qvc3Zjc3Vicy5jICB8ICAzICstLQ0KPiAgMTIgZmlsZXMgY2hhbmdlZCwgNTkgaW5zZXJ0aW9u cygrKSwgNjAgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvZnMvbG9ja2QvY2xudDR4 ZHIuYyBiL2ZzL2xvY2tkL2NsbnQ0eGRyLmMNCj4gaW5kZXggYzM0OWZjMGY5YjgwLi5lYzY0NzNk MTk0ZmQgMTAwNjQ0DQo+IC0tLSBhL2ZzL2xvY2tkL2NsbnQ0eGRyLmMNCj4gKysrIGIvZnMvbG9j a2QvY2xudDR4ZHIuYw0KPiBAQCAtMTMxLDcgKzEzMSw3IEBAIHN0YXRpYyBpbnQgZGVjb2RlX25l dG9iaihzdHJ1Y3QgeGRyX3N0cmVhbSAqeGRyLA0KPiAgCV9fYmUzMiAqcDsNCj4gIA0KPiAgCXAg PSB4ZHJfaW5saW5lX2RlY29kZSh4ZHIsIDQpOw0KPiAtCWlmICh1bmxpa2VseShwID09IE5VTEwp KQ0KPiArCWlmICh1bmxpa2VseSghcCkpDQoNCk9oIFNUT1Agd2l0aCB0aGUgY2hlY2twYXRjaCB3 YW5rZmVzdCENCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRh aW5lciwgUHJpbWFyeURhdGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg= ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] lockd: Adjust 61 checks for null pointers @ 2017-08-18 15:53 ` Trond Myklebust 0 siblings, 0 replies; 11+ messages in thread From: Trond Myklebust @ 2017-08-18 15:53 UTC (permalink / raw) To: colin.king@canonical.com, bfields@fieldses.org, hch, linux-nfs@vger.kernel.org, jlayton@poochiereds.net, elfring@users.sourceforge.net, bcodding redhat, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org On Thu, 2017-08-17 at 16:34 +0200, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Thu, 17 Aug 2017 16:00:18 +0200 > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > The script “checkpatch.pl” pointed information out like the > following. > > Comparison to NULL could be written … > > Thus fix the affected source code places. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > fs/lockd/clnt4xdr.c | 12 ++++++------ > fs/lockd/clntlock.c | 10 +++++----- > fs/lockd/clntproc.c | 12 ++++++------ > fs/lockd/clntxdr.c | 12 ++++++------ > fs/lockd/host.c | 22 +++++++++++----------- > fs/lockd/mon.c | 16 ++++++++-------- > fs/lockd/svc.c | 4 ++-- > fs/lockd/svc4proc.c | 6 +++--- > fs/lockd/svclock.c | 14 +++++++------- > fs/lockd/svcproc.c | 6 +++--- > fs/lockd/svcshare.c | 2 +- > fs/lockd/svcsubs.c | 3 +-- > 12 files changed, 59 insertions(+), 60 deletions(-) > > diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c > index c349fc0f9b80..ec6473d194fd 100644 > --- a/fs/lockd/clnt4xdr.c > +++ b/fs/lockd/clnt4xdr.c > @@ -131,7 +131,7 @@ static int decode_netobj(struct xdr_stream *xdr, > __be32 *p; > > p = xdr_inline_decode(xdr, 4); > - if (unlikely(p == NULL)) > + if (unlikely(!p)) Oh STOP with the checkpatch wankfest! -- Trond Myklebust Linux NFS client maintainer, PrimaryData trond.myklebust@primarydata.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] lockd: Adjust 61 checks for null pointers @ 2017-08-18 15:53 ` Trond Myklebust 0 siblings, 0 replies; 11+ messages in thread From: Trond Myklebust @ 2017-08-18 15:53 UTC (permalink / raw) To: colin.king@canonical.com, bfields@fieldses.org, hch, linux-nfs@vger.kernel.org, jlayton@poochiereds.net, elfring@users.sourceforge.net, bcodding redhat, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org T24gVGh1LCAyMDE3LTA4LTE3IGF0IDE2OjM0ICswMjAwLCBTRiBNYXJrdXMgRWxmcmluZyB3cm90 ZToNCj4gRnJvbTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdAdXNlcnMuc291cmNlZm9yZ2UubmV0 Pg0KPiBEYXRlOiBUaHUsIDE3IEF1ZyAyMDE3IDE2OjAwOjE4ICswMjAwDQo+IE1JTUUtVmVyc2lv bjogMS4wDQo+IENvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOA0KPiBDb250 ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0DQo+IA0KPiBUaGUgc2NyaXB0IOKAnGNoZWNrcGF0 Y2gucGzigJ0gcG9pbnRlZCBpbmZvcm1hdGlvbiBvdXQgbGlrZSB0aGUNCj4gZm9sbG93aW5nLg0K PiANCj4gQ29tcGFyaXNvbiB0byBOVUxMIGNvdWxkIGJlIHdyaXR0ZW4g4oCmDQo+IA0KPiBUaHVz IGZpeCB0aGUgYWZmZWN0ZWQgc291cmNlIGNvZGUgcGxhY2VzLg0KPiANCj4gU2lnbmVkLW9mZi1i eTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdAdXNlcnMuc291cmNlZm9yZ2UubmV0Pg0KPiAtLS0N Cj4gIGZzL2xvY2tkL2NsbnQ0eGRyLmMgfCAxMiArKysrKystLS0tLS0NCj4gIGZzL2xvY2tkL2Ns bnRsb2NrLmMgfCAxMCArKysrKy0tLS0tDQo+ICBmcy9sb2NrZC9jbG50cHJvYy5jIHwgMTIgKysr KysrLS0tLS0tDQo+ICBmcy9sb2NrZC9jbG50eGRyLmMgIHwgMTIgKysrKysrLS0tLS0tDQo+ICBm cy9sb2NrZC9ob3N0LmMgICAgIHwgMjIgKysrKysrKysrKystLS0tLS0tLS0tLQ0KPiAgZnMvbG9j a2QvbW9uLmMgICAgICB8IDE2ICsrKysrKysrLS0tLS0tLS0NCj4gIGZzL2xvY2tkL3N2Yy5jICAg ICAgfCAgNCArKy0tDQo+ICBmcy9sb2NrZC9zdmM0cHJvYy5jIHwgIDYgKysrLS0tDQo+ICBmcy9s b2NrZC9zdmNsb2NrLmMgIHwgMTQgKysrKysrKy0tLS0tLS0NCj4gIGZzL2xvY2tkL3N2Y3Byb2Mu YyAgfCAgNiArKystLS0NCj4gIGZzL2xvY2tkL3N2Y3NoYXJlLmMgfCAgMiArLQ0KPiAgZnMvbG9j a2Qvc3Zjc3Vicy5jICB8ICAzICstLQ0KPiAgMTIgZmlsZXMgY2hhbmdlZCwgNTkgaW5zZXJ0aW9u cygrKSwgNjAgZGVsZXRpb25zKC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvZnMvbG9ja2QvY2xudDR4 ZHIuYyBiL2ZzL2xvY2tkL2NsbnQ0eGRyLmMNCj4gaW5kZXggYzM0OWZjMGY5YjgwLi5lYzY0NzNk MTk0ZmQgMTAwNjQ0DQo+IC0tLSBhL2ZzL2xvY2tkL2NsbnQ0eGRyLmMNCj4gKysrIGIvZnMvbG9j a2QvY2xudDR4ZHIuYw0KPiBAQCAtMTMxLDcgKzEzMSw3IEBAIHN0YXRpYyBpbnQgZGVjb2RlX25l dG9iaihzdHJ1Y3QgeGRyX3N0cmVhbSAqeGRyLA0KPiAgCV9fYmUzMiAqcDsNCj4gIA0KPiAgCXAg PSB4ZHJfaW5saW5lX2RlY29kZSh4ZHIsIDQpOw0KPiAtCWlmICh1bmxpa2VseShwID09IE5VTEwp KQ0KPiArCWlmICh1bmxpa2VseSghcCkpDQoNCk9oIFNUT1Agd2l0aCB0aGUgY2hlY2twYXRjaCB3 YW5rZmVzdCENCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRh aW5lciwgUHJpbWFyeURhdGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg== ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] lockd: Adjust 61 checks for null pointers 2017-08-18 15:53 ` Trond Myklebust @ 2017-08-18 16:04 ` Jeff Layton -1 siblings, 0 replies; 11+ messages in thread From: Jeff Layton @ 2017-08-18 16:04 UTC (permalink / raw) To: Trond Myklebust, colin.king@canonical.com, bfields@fieldses.org, hch, linux-nfs@vger.kernel.org, elfring@users.sourceforge.net, bcodding redhat, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org On Fri, 2017-08-18 at 15:53 +0000, Trond Myklebust wrote: > On Thu, 2017-08-17 at 16:34 +0200, SF Markus Elfring wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > > Date: Thu, 17 Aug 2017 16:00:18 +0200 > > MIME-Version: 1.0 > > Content-Type: text/plain; charset=UTF-8 > > Content-Transfer-Encoding: 8bit > > > > The script “checkpatch.pl” pointed information out like the > > following. > > > > Comparison to NULL could be written … > > > > Thus fix the affected source code places. > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > --- > > fs/lockd/clnt4xdr.c | 12 ++++++------ > > fs/lockd/clntlock.c | 10 +++++----- > > fs/lockd/clntproc.c | 12 ++++++------ > > fs/lockd/clntxdr.c | 12 ++++++------ > > fs/lockd/host.c | 22 +++++++++++----------- > > fs/lockd/mon.c | 16 ++++++++-------- > > fs/lockd/svc.c | 4 ++-- > > fs/lockd/svc4proc.c | 6 +++--- > > fs/lockd/svclock.c | 14 +++++++------- > > fs/lockd/svcproc.c | 6 +++--- > > fs/lockd/svcshare.c | 2 +- > > fs/lockd/svcsubs.c | 3 +-- > > 12 files changed, 59 insertions(+), 60 deletions(-) > > > > diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c > > index c349fc0f9b80..ec6473d194fd 100644 > > --- a/fs/lockd/clnt4xdr.c > > +++ b/fs/lockd/clnt4xdr.c > > @@ -131,7 +131,7 @@ static int decode_netobj(struct xdr_stream *xdr, > > __be32 *p; > > > > p = xdr_inline_decode(xdr, 4); > > - if (unlikely(p = NULL)) > > + if (unlikely(!p)) > > Oh STOP with the checkpatch wankfest! > :) To elaborate: these kinds of patches are particularly unwelcome. In particular, these sorts of changes make it difficult to backport later patches to earlier kernels. If you're doing meaningful work in these areas of code, then feel free to change the style at the same time. If not though, it's best to leave them alone. Cheers, -- Jeff Layton <jlayton@redhat.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] lockd: Adjust 61 checks for null pointers @ 2017-08-18 16:04 ` Jeff Layton 0 siblings, 0 replies; 11+ messages in thread From: Jeff Layton @ 2017-08-18 16:04 UTC (permalink / raw) To: Trond Myklebust, colin.king@canonical.com, bfields@fieldses.org, hch, linux-nfs@vger.kernel.org, elfring@users.sourceforge.net, bcodding redhat, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org On Fri, 2017-08-18 at 15:53 +0000, Trond Myklebust wrote: > On Thu, 2017-08-17 at 16:34 +0200, SF Markus Elfring wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > > Date: Thu, 17 Aug 2017 16:00:18 +0200 > > MIME-Version: 1.0 > > Content-Type: text/plain; charset=UTF-8 > > Content-Transfer-Encoding: 8bit > > > > The script “checkpatch.pl” pointed information out like the > > following. > > > > Comparison to NULL could be written … > > > > Thus fix the affected source code places. > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > --- > > fs/lockd/clnt4xdr.c | 12 ++++++------ > > fs/lockd/clntlock.c | 10 +++++----- > > fs/lockd/clntproc.c | 12 ++++++------ > > fs/lockd/clntxdr.c | 12 ++++++------ > > fs/lockd/host.c | 22 +++++++++++----------- > > fs/lockd/mon.c | 16 ++++++++-------- > > fs/lockd/svc.c | 4 ++-- > > fs/lockd/svc4proc.c | 6 +++--- > > fs/lockd/svclock.c | 14 +++++++------- > > fs/lockd/svcproc.c | 6 +++--- > > fs/lockd/svcshare.c | 2 +- > > fs/lockd/svcsubs.c | 3 +-- > > 12 files changed, 59 insertions(+), 60 deletions(-) > > > > diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c > > index c349fc0f9b80..ec6473d194fd 100644 > > --- a/fs/lockd/clnt4xdr.c > > +++ b/fs/lockd/clnt4xdr.c > > @@ -131,7 +131,7 @@ static int decode_netobj(struct xdr_stream *xdr, > > __be32 *p; > > > > p = xdr_inline_decode(xdr, 4); > > - if (unlikely(p == NULL)) > > + if (unlikely(!p)) > > Oh STOP with the checkpatch wankfest! > :) To elaborate: these kinds of patches are particularly unwelcome. In particular, these sorts of changes make it difficult to backport later patches to earlier kernels. If you're doing meaningful work in these areas of code, then feel free to change the style at the same time. If not though, it's best to leave them alone. Cheers, -- Jeff Layton <jlayton@redhat.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-08-18 16:04 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-08-17 14:32 [PATCH 0/2] lockd: Adjustments for some function implementations SF Markus Elfring 2017-08-17 14:32 ` SF Markus Elfring 2017-08-17 14:33 ` [PATCH 1/2] lockd: Delete an error message for a failed memory allocation in reclaimer() SF Markus Elfring 2017-08-17 14:33 ` SF Markus Elfring 2017-08-17 14:34 ` [PATCH 2/2] lockd: Adjust 61 checks for null pointers SF Markus Elfring 2017-08-17 14:34 ` SF Markus Elfring 2017-08-18 15:53 ` Trond Myklebust 2017-08-18 15:53 ` Trond Myklebust 2017-08-18 15:53 ` Trond Myklebust 2017-08-18 16:04 ` Jeff Layton 2017-08-18 16:04 ` Jeff Layton
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.