staging: speakup: Clean up tests if NULL returned on failure
authorsimran singhal <singhalsimran0@gmail.com>
Sat, 4 Mar 2017 16:46:54 +0000 (22:16 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Mar 2017 13:27:13 +0000 (14:27 +0100)
Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/main.c

index 5c174c98f1080fcabc9f3a0403d907d86ae51495..96e25eb631b5aaa6e25f7b9059ffee0284f23067 100644 (file)
@@ -1324,7 +1324,7 @@ static int speakup_allocate(struct vc_data *vc)
        if (speakup_console[vc_num] == NULL) {
                speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]),
                                                  GFP_ATOMIC);
-               if (speakup_console[vc_num] == NULL)
+               if (!speakup_console[vc_num])
                        return -ENOMEM;
                speakup_date(vc);
        } else if (!spk_parked)