Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] staging: lirc_zilog: Clean up tests if NULL returned on failure

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>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

simran singhal and committed by
Mauro Carvalho Chehab
a1aae088 6eb1951d

+3 -3
+3 -3
drivers/staging/media/lirc/lirc_zilog.c
··· 1475 1475 ir = get_ir_device_by_adapter(adap); 1476 1476 if (ir == NULL) { 1477 1477 ir = kzalloc(sizeof(struct IR), GFP_KERNEL); 1478 - if (ir == NULL) { 1478 + if (!ir) { 1479 1479 ret = -ENOMEM; 1480 1480 goto out_no_ir; 1481 1481 } ··· 1515 1515 1516 1516 /* Set up a struct IR_tx instance */ 1517 1517 tx = kzalloc(sizeof(struct IR_tx), GFP_KERNEL); 1518 - if (tx == NULL) { 1518 + if (!tx) { 1519 1519 ret = -ENOMEM; 1520 1520 goto out_put_xx; 1521 1521 } ··· 1559 1559 1560 1560 /* Set up a struct IR_rx instance */ 1561 1561 rx = kzalloc(sizeof(struct IR_rx), GFP_KERNEL); 1562 - if (rx == NULL) { 1562 + if (!rx) { 1563 1563 ret = -ENOMEM; 1564 1564 goto out_put_xx; 1565 1565 }