staging: lustre: mgc: Use !x to check for kzalloc failure
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 20 Jun 2015 16:59:06 +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/mgc/mgc_request.c

index 174dfc32876b5860b5131b31a1b36f330e0ddbba..562bd95bdcb9845c8b8930e04720d8a7a3a92c6b 100644 (file)
@@ -1128,7 +1128,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
        LASSERT(cfg->cfg_sb == cfg->cfg_instance);
 
        inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
-       if (inst == NULL)
+       if (!inst)
                return -ENOMEM;
 
        if (!IS_SERVER(lsi)) {
@@ -1493,7 +1493,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc,
                lsi = s2lsi(cld->cld_cfg.cfg_sb);
 
        env = kzalloc(sizeof(*env), GFP_NOFS);
-       if (env == NULL)
+       if (!env)
                return -ENOMEM;
 
        rc = lu_env_init(env, LCT_MG_THREAD);