staging: vc04_services: Clean up tests if NULL returned on failure
authorsimran singhal <singhalsimran0@gmail.com>
Sat, 4 Mar 2017 16:46:55 +0000 (22:16 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Mar 2017 18:06:36 +0000 (19:06 +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/vc04_services/interface/vchiq_arm/vchiq_util.c

index e0ba0ed704fd1222ffd1c064450d80db986ff867..7fa0310e7b9e3afd43f6cd665fa5732d1350599b 100644 (file)
@@ -52,7 +52,7 @@ int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size)
        sema_init(&queue->push, 0);
 
        queue->storage = kzalloc(size * sizeof(VCHIQ_HEADER_T *), GFP_KERNEL);
-       if (queue->storage == NULL) {
+       if (!queue->storage) {
                vchiu_queue_delete(queue);
                return 0;
        }