staging: gdm724x: use !x instead of x == NULL
Subsystems (4)
PATCH 1/5 staging: gdm724x: use !x instead of x == NULL
Functions like devm_kzalloc, kmalloc_array, devm_ioremap, usb_alloc_urb, alloc_netdev return NULL as a return value on failure. Generally, When NULL represents failure, !x is commonly used.
This patch cleans up the tests on the results of these functions, thereby using !x instead of x == NULL or NULL == x. This is done via following coccinelle script:
@prob_7@
identifier x;
statement S;
@@
(
x = devm_kzalloc(...);
|
x = usb_alloc_urb(...);
|
x = kmalloc_array(...);
|
x = devm_ioremap(...);
|
x = alloc_netdev(...);
)
...
- if(NULL == x)
+ if(!x)
S
Further we have used isomorphism characteristics of coccinelle to indicate x == NULL and NULL == x are equivalent. This is done via following iso script.
Expression
@ is_null @ expression X; @@
X == NULL <=> NULL == X
--- drivers/staging/gdm724x/gdm_lte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gdm724x/gdm_lte.c +1 -1
@@ -889,7 +889,7 @@ int register_lte_device(struct phy_dev *phy_dev,/* Allocate netdev */ net =alloc_netdev (sizeof (struct nic ), pdn_dev_name,NET_NAME_UNKNOWN , ether_setup); -if (net ==NULL ) { +if (!net) {pr_err ("alloc_netdev failed\n" ); ret = -ENOMEM ; goto err;
Signature · 1 line
1.9.1
PATCH 2/5 Staging: gdm72xx: use !x instead of x == NULL
Functions like devm_kzalloc, kmalloc_array, devm_ioremap, usb_alloc_urb, alloc_netdev return NULL as a return value on failure. Generally, When NULL represents failure, !x is commonly used.
This patch cleans up the tests on the results of these functions, thereby using !x instead of x == NULL or NULL == x. This is done via following coccinelle script:
@prob_7@
identifier x;
statement S;
@@
(
x = devm_kzalloc(...);
|
x = usb_alloc_urb(...);
|
x = kmalloc_array(...);
|
x = devm_ioremap(...);
|
x = alloc_netdev(...);
)
...
- if(NULL == x)
+ if(!x)
S
Further we have used isomorphism characteristics of coccinelle to indicate x == NULL and NULL == x are equivalent. This is done via following iso script.
Expression
@ is_null @ expression X; @@
X == NULL <=> NULL == X
--- drivers/staging/gdm72xx/gdm_wimax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gdm72xx/gdm_wimax.c +1 -1
@@ -749,7 +749,7 @@ int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev) dev =alloc_netdev (sizeof (*nic),"wm%d" ,NET_NAME_UNKNOWN , ether_setup); -if (dev ==NULL ) { +if (!dev) {pr_err ("alloc_etherdev failed\n" );return -ENOMEM ; }
Signature · 1 line
1.9.1
PATCH 3/5 Staging: goldfish: use !x instead of x == NULL
In reply to Somya AnandFunctions like devm_kzalloc, kmalloc_array, devm_ioremap, usb_alloc_urb, alloc_netdev return NULL as a return value on failure. Generally, When NULL represents failure, !x is commonly used.
This patch cleans up the tests on the results of these functions, thereby using !x instead of x == NULL or NULL == x. This is done via following coccinelle script:
@prob_7@
identifier x;
statement S;
@@
(
x = devm_kzalloc(...);
|
x = usb_alloc_urb(...);
|
x = kmalloc_array(...);
|
x = devm_ioremap(...);
|
x = alloc_netdev(...);
)
...
- if(NULL == x)
+ if(!x)
S
Further we have used isomorphism characteristics of coccinelle to indicate x == NULL and NULL == x are equivalent. This is done via following iso script.
Expression
@ is_null @ expression X; @@
X == NULL <=> NULL == X
--- drivers/staging/goldfish/goldfish_audio.c | 2 +- drivers/staging/goldfish/goldfish_nand.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/goldfish/goldfish_audio.c +1 -1
@@ -273,7 +273,7 @@ static int goldfish_audio_probe(struct platform_device *pdev)dma_addr_t buf_addr; data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL ); -if (data ==NULL ) +if (!data)return -ENOMEM ;spin_lock_init (&data->lock);init_waitqueue_head (&data->wait);
drivers/staging/goldfish/goldfish_nand.c +3 -3
@@ -330,7 +330,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev, mtd->priv = nand; name =devm_kzalloc (&pdev->dev, name_len +1 ,GFP_KERNEL ); -if (name ==NULL ) +if (!name)return -ENOMEM ; mtd->name = name;
@@ -383,7 +383,7 @@ static int goldfish_nand_probe(struct platform_device *pdev)return -ENODEV ; base =devm_ioremap (&pdev->dev, r->start,PAGE_SIZE ); -if (base ==NULL ) +if (!base)return -ENOMEM ; version =readl (base +NAND_VERSION );
@@ -399,7 +399,7 @@ static int goldfish_nand_probe(struct platform_device *pdev) nand =devm_kzalloc (&pdev->dev,sizeof (*nand) +sizeof (struct mtd_info ) * num_dev,GFP_KERNEL ); -if (nand ==NULL ) +if (!nand)return -ENOMEM ;mutex_init (&nand->lock);
Signature · 1 line
1.9.1
PATCH 4/5 Staging: iio: use !x instead of x == NULL
In reply to Somya AnandFunctions like devm_kzalloc, kmalloc_array, devm_ioremap, usb_alloc_urb, alloc_netdev return NULL as a return value on failure. Generally, When NULL represents failure, !x is commonly used.
This patch cleans up the tests on the results of these functions, thereby using !x instead of x == NULL or NULL == x. This is done via following coccinelle script:
@prob_7@
identifier x;
statement S;
@@
(
x = devm_kzalloc(...);
|
x = usb_alloc_urb(...);
|
x = kmalloc_array(...);
|
x = devm_ioremap(...);
|
x = alloc_netdev(...);
)
...
- if(NULL == x)
+ if(!x)
S
Further we have used isomorphism characteristics of coccinelle to indicate x == NULL and NULL == x are equivalent. This is done via following iso script.
Expression
@ is_null @ expression X; @@
X == NULL <=> NULL == X
--- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/trigger/iio-trig-bfin-timer.c +1 -1
@@ -183,7 +183,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)int ret; st =devm_kzalloc (&pdev->dev,sizeof (*st),GFP_KERNEL ); -if (st ==NULL ) +if (!st)return -ENOMEM ; st->irq =platform_get_irq (pdev,0 );
Signature · 1 line
1.9.1
PATCH 5/5 Staging: nvec: use !x instead of x == NULL
In reply to Somya AnandFunctions like devm_kzalloc, kmalloc_array, devm_ioremap, usb_alloc_urb, alloc_netdev return NULL as a return value on failure. Generally, When NULL represents failure, !x is commonly used.
This patch cleans up the tests on the results of these functions, thereby using !x instead of x == NULL or NULL == x. This is done via following coccinelle script:
@prob_7@
identifier x;
statement S;
@@
(
x = devm_kzalloc(...);
|
x = usb_alloc_urb(...);
|
x = kmalloc_array(...);
|
x = devm_ioremap(...);
|
x = alloc_netdev(...);
)
...
- if(NULL == x)
+ if(!x)
S
Further we have used isomorphism characteristics of coccinelle to indicate x == NULL and NULL == x are equivalent. This is done via following iso script.
Expression
@ is_null @ expression X; @@
X == NULL <=> NULL == X
--- drivers/staging/nvec/nvec.c | 2 +- drivers/staging/nvec/nvec_paz00.c | 2 +- drivers/staging/nvec/nvec_power.c | 2 +- drivers/staging/nvec/nvec_ps2.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/nvec/nvec.c +1 -1
@@ -803,7 +803,7 @@ static int tegra_nvec_probe(struct platform_device *pdev) } nvec =devm_kzalloc (&pdev->dev,sizeof (struct nvec_chip ),GFP_KERNEL ); -if (nvec ==NULL ) +if (!nvec)return -ENOMEM ;platform_set_drvdata (pdev, nvec);
drivers/staging/nvec/nvec_paz00.c +1 -1
@@ -51,7 +51,7 @@ static int nvec_paz00_probe(struct platform_device *pdev)int ret =0 ; led =devm_kzalloc (&pdev->dev,sizeof (*led),GFP_KERNEL ); -if (led ==NULL ) +if (!led)return -ENOMEM ; led->cdev.max_brightness =NVEC_LED_MAX ;
drivers/staging/nvec/nvec_power.c +1 -1
@@ -378,7 +378,7 @@ static int nvec_power_probe(struct platform_device *pdev)struct nvec_chip *nvec =dev_get_drvdata (pdev->dev.parent); power =devm_kzalloc (&pdev->dev,sizeof (struct nvec_power ),GFP_NOWAIT ); -if (power ==NULL ) +if (!power)return -ENOMEM ;dev_set_drvdata (&pdev->dev, power);
drivers/staging/nvec/nvec_ps2.c +1 -1
@@ -109,7 +109,7 @@ static int nvec_mouse_probe(struct platform_device *pdev)char mouse_reset[] = {NVEC_PS2 ,SEND_COMMAND ,PSMOUSE_RST ,3 }; ser_dev =devm_kzalloc (&pdev->dev,sizeof (struct serio ),GFP_KERNEL ); -if (ser_dev ==NULL ) +if (!ser_dev)return -ENOMEM ; ser_dev->id.type =SERIO_PS_PSTHRU ;
Signature · 1 line
1.9.1