Commit 597851ac authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: ptlrpc: Use !x to check for kzalloc failure

!x is more normal for kzalloc failure in the kernel.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x;
statement S1, S2;
@@

x = kzalloc(...);
if (
- x == NULL
+ !x
 ) S1 else S2
// </smpl>
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3408e9ae
...@@ -971,7 +971,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set, ...@@ -971,7 +971,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
struct ptlrpc_set_cbdata *cbdata; struct ptlrpc_set_cbdata *cbdata;
cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS); cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS);
if (cbdata == NULL) if (!cbdata)
return -ENOMEM; return -ENOMEM;
cbdata->psc_interpret = fn; cbdata->psc_interpret = fn;
......
...@@ -652,7 +652,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, ...@@ -652,7 +652,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
return -EINVAL; return -EINVAL;
cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS); cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
if (cmd == NULL) if (!cmd)
return -ENOMEM; return -ENOMEM;
/** /**
* strsep() modifies its argument, so keep a copy * strsep() modifies its argument, so keep a copy
...@@ -819,7 +819,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) ...@@ -819,7 +819,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
} }
srhi = kzalloc(sizeof(*srhi), GFP_NOFS); srhi = kzalloc(sizeof(*srhi), GFP_NOFS);
if (srhi == NULL) if (!srhi)
return NULL; return NULL;
srhi->srhi_seq = 0; srhi->srhi_seq = 0;
...@@ -1219,7 +1219,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, ...@@ -1219,7 +1219,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
char *tmpbuf; char *tmpbuf;
kbuf = kzalloc(BUFLEN, GFP_NOFS); kbuf = kzalloc(BUFLEN, GFP_NOFS);
if (kbuf == NULL) if (!kbuf)
return -ENOMEM; return -ENOMEM;
/* /*
...@@ -1303,7 +1303,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, ...@@ -1303,7 +1303,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
return -EINVAL; return -EINVAL;
kbuf = kzalloc(count + 1, GFP_NOFS); kbuf = kzalloc(count + 1, GFP_NOFS);
if (kbuf == NULL) if (!kbuf)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(kbuf, buffer, count)) { if (copy_from_user(kbuf, buffer, count)) {
......
...@@ -1156,7 +1156,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) ...@@ -1156,7 +1156,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
} }
desc = kzalloc(sizeof(*desc), GFP_NOFS); desc = kzalloc(sizeof(*desc), GFP_NOFS);
if (desc == NULL) { if (!desc) {
rc = -ENOMEM; rc = -ENOMEM;
goto fail; goto fail;
} }
......
...@@ -739,7 +739,7 @@ static int ptlrpcd_init(void) ...@@ -739,7 +739,7 @@ static int ptlrpcd_init(void)
size = offsetof(struct ptlrpcd, pd_threads[nthreads]); size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
ptlrpcds = kzalloc(size, GFP_NOFS); ptlrpcds = kzalloc(size, GFP_NOFS);
if (ptlrpcds == NULL) { if (!ptlrpcds) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
......
...@@ -415,7 +415,7 @@ static int enc_pools_add_pages(int npages) ...@@ -415,7 +415,7 @@ static int enc_pools_add_pages(int npages)
for (i = 0; i < npools; i++) { for (i = 0; i < npools; i++) {
pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
if (pools[i] == NULL) if (!pools[i])
goto out_pools; goto out_pools;
for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) { for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) {
......
...@@ -564,7 +564,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname, ...@@ -564,7 +564,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname,
return NULL; return NULL;
conf = kzalloc(sizeof(*conf), GFP_NOFS); conf = kzalloc(sizeof(*conf), GFP_NOFS);
if (conf == NULL) if (!conf)
return NULL; return NULL;
strcpy(conf->sc_fsname, fsname); strcpy(conf->sc_fsname, fsname);
......
...@@ -444,7 +444,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, ...@@ -444,7 +444,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp,
LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN); LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN);
plsec = kzalloc(sizeof(*plsec), GFP_NOFS); plsec = kzalloc(sizeof(*plsec), GFP_NOFS);
if (plsec == NULL) if (!plsec)
return NULL; return NULL;
/* /*
......
...@@ -732,7 +732,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, ...@@ -732,7 +732,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]), service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
GFP_NOFS); GFP_NOFS);
if (service == NULL) { if (!service) {
kfree(cpts); kfree(cpts);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
...@@ -2298,7 +2298,7 @@ static int ptlrpc_main(void *arg) ...@@ -2298,7 +2298,7 @@ static int ptlrpc_main(void *arg)
} }
env = kzalloc(sizeof(*env), GFP_NOFS); env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL) { if (!env) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_srv_fini; goto out_srv_fini;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment