Skip to contentSkip to conversation

staging: vc04_services: Remove explicit NULL comparison

PATCH New Gargi Sharma 1 participant 1 message Feb 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: vc04_services: Remove explicit NULL comparison

Replace explicit NULL comparison with ! operator to simplify code.

Found with Coccinelle script:
@@
expression ptr;
position p;
statement s0, s1;
@@

ptr@p = \(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...)
... when != ptr

if (
(
+ !
ptr
- == NULL
)
) s0 else s1

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1 -1
index 1dc8627..b1db750 100644
@@ -1572,7 +1572,7 @@ dump_phys_mem(void *virt_addr, u32 num_bytes)
 	num_pages = (offset + num_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
 
 	pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
-	if (pages == NULL) {
+	if (!pages) {
 		vchiq_log_error(vchiq_arm_log_level,
 			"Unable to allocation memory for %d pages\n",
 			num_pages);
Signature · 1 line
2.7.4