]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: lustre: ptlrpc: Use !x to check for kzalloc failure
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 20 Jun 2015 16:59:10 +0000 (18:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 02:35:53 +0000 (19:35 -0700)
!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: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ptlrpc/client.c
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
drivers/staging/lustre/lustre/ptlrpc/nrs.c
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
drivers/staging/lustre/lustre/ptlrpc/sec_config.c
drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
drivers/staging/lustre/lustre/ptlrpc/service.c

index a12cd66b23650db841853e165e6331c903cfcb6b..c83a34a01e659cea3b2d583d1d1711e97f2d953b 100644 (file)
@@ -971,7 +971,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
        struct ptlrpc_set_cbdata *cbdata;
 
        cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS);
-       if (cbdata == NULL)
+       if (!cbdata)
                return -ENOMEM;
 
        cbdata->psc_interpret = fn;
index aaaabbf5f1b9807770d7e743e3c62035fd8809bf..53f9af1f2f3eaa109599b9a3e610171acf7ecd64 100644 (file)
@@ -652,7 +652,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
                return -EINVAL;
 
        cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
-       if (cmd == NULL)
+       if (!cmd)
                return -ENOMEM;
        /**
         * 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)
        }
 
        srhi = kzalloc(sizeof(*srhi), GFP_NOFS);
-       if (srhi == NULL)
+       if (!srhi)
                return NULL;
 
        srhi->srhi_seq = 0;
@@ -1219,7 +1219,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
        char *tmpbuf;
 
        kbuf = kzalloc(BUFLEN, GFP_NOFS);
-       if (kbuf == NULL)
+       if (!kbuf)
                return -ENOMEM;
 
        /*
@@ -1303,7 +1303,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
                return -EINVAL;
 
        kbuf = kzalloc(count + 1, GFP_NOFS);
-       if (kbuf == NULL)
+       if (!kbuf)
                return -ENOMEM;
 
        if (copy_from_user(kbuf, buffer, count)) {
index 9516acadb7a16d5697f4b05bcd61565882ae3643..d37cdd5ac58065481ec7403c7d9962cef90df1c4 100644 (file)
@@ -1156,7 +1156,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
        }
 
        desc = kzalloc(sizeof(*desc), GFP_NOFS);
-       if (desc == NULL) {
+       if (!desc) {
                rc = -ENOMEM;
                goto fail;
        }
index e591cff323ece570c342ef32e0b7329e59a1c47d..17cc81d5074f3706c3ad97463ce0b15492cd791f 100644 (file)
@@ -739,7 +739,7 @@ static int ptlrpcd_init(void)
 
        size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
        ptlrpcds = kzalloc(size, GFP_NOFS);
-       if (ptlrpcds == NULL) {
+       if (!ptlrpcds) {
                rc = -ENOMEM;
                goto out;
        }
index 69d73c43069636d310b5d7fc1c0a36162f6ae988..2ee3e8b2e879eac164aa73e7454fd5393d89c416 100644 (file)
@@ -415,7 +415,7 @@ static int enc_pools_add_pages(int npages)
 
        for (i = 0; i < npools; i++) {
                pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
-               if (pools[i] == NULL)
+               if (!pools[i])
                        goto out_pools;
 
                for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) {
index 31da43e8b3c62942e01a53e328694ea0bd3e9100..e7f2f333257db9f964ac590aff1dad7b6979a064 100644 (file)
@@ -564,7 +564,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname,
                return NULL;
 
        conf = kzalloc(sizeof(*conf), GFP_NOFS);
-       if (conf == NULL)
+       if (!conf)
                return NULL;
 
        strcpy(conf->sc_fsname, fsname);
index 53ce0d14bd469f5d172dd369509ae84110bf8c75..a243db60f69776ddc4b9c197d67e39d6a77b9a65 100644 (file)
@@ -444,7 +444,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp,
        LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN);
 
        plsec = kzalloc(sizeof(*plsec), GFP_NOFS);
-       if (plsec == NULL)
+       if (!plsec)
                return NULL;
 
        /*
index 9117f1c15a8e88dbacda3fa2b8e3afb3c94d9690..56a86317ded73dab19148214b923d97c3bb3497c 100644 (file)
@@ -732,7 +732,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
 
        service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
                          GFP_NOFS);
-       if (service == NULL) {
+       if (!service) {
                kfree(cpts);
                return ERR_PTR(-ENOMEM);
        }
@@ -2298,7 +2298,7 @@ static int ptlrpc_main(void *arg)
        }
 
        env = kzalloc(sizeof(*env), GFP_NOFS);
-       if (env == NULL) {
+       if (!env) {
                rc = -ENOMEM;
                goto out_srv_fini;
        }