Staging: wilc1000: Remove null check before kfree
PATCH 1/3 Staging: wilc1000: Remove null check before kfree
kfree on NULL pointer is a no-op.
This patch uses the following semantic patch to find such an instance where NULL check is present before kfree.
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);
@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>smpl>
--- drivers/staging/wilc1000/linux_wlan.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +1 -2
@@ -2343,8 +2343,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) done: -if (buff !=NULL ) -kfree (buff); +kfree (buff);return s32Error; }
Signature · 1 line
2.1.0
PATCH 2/3 Staging: lustre: libcfs: Remove unnecessary cast on void*
This patch does away with the cast on void * as it is unnecessary.
Semantic patch used is as follows:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
*((T *)e)
|
((T *)x)[...]
|
((T *)x)->f
|
- (void *)
e
)
--- drivers/staging/lustre/lustre/libcfs/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/libcfs/module.c +1 -1
@@ -335,7 +335,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *areturn -ENOMEM ;/* 'cmd' and permissions get checked in our arch-specific caller */ -if (libcfs_ioctl_getdata (buf, buf +800 , (void *)arg)) { +if (libcfs_ioctl_getdata (buf, buf +800 , arg)) {CERROR ("PORTALS ioctl: data error\n" ); err = -EINVAL ; goto out;
Signature · 1 line
2.1.0
PATCH 3/3 Staging: unisys: Remove useless cast on void pointer
In reply to Shraddha Barkevoid pointers do not need to be cast to other pointer types.
The semantic patch used to find this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
*((T *)e)
|
((T *)x)[...]
|
((T *)x)->f
|
- (T *)
e
)
--- drivers/staging/unisys/visorbus/visorbus_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/unisys/visorbus/visorbus_main.c +1 -1
@@ -677,7 +677,7 @@ unregister_driver_attributes(struct visor_driver *drv)static void dev_periodic_work (void *xdev) { -struct visor_device *dev = (struct visor_device *)xdev; +struct visor_device *dev = xdev;struct visor_driver *drv =to_visor_driver (dev->device.driver);down (&dev->visordriver_callback_lock);
Signature · 1 line
2.1.0
Quoted 1 line · Shraddha Barke
kfree on NULL pointer is a no-op.
Hi, please don't CC the hpdd-discuss list, nor Oleg or I for patches unrelated to Lustre.
Cheers, Andreas
Quoted 32 lines
This patch uses the following semantic patch to find such an instance where NULL check is present before kfree.
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);
@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>smpl>Signed-off-by Shraddha Barke <[email protected]>---
drivers/staging/wilc1000/linux_wlan.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/wilc1000/linux_wlan.c +0
-0@@ -2343,8 +2343,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)done:
drivers/staging/wilc1000/linux_wlan.c +1
-2-if (buff !=NULL ) -kfree (buff); +kfree (buff);
Quoted 6 lines
return s32Error; }Signature · 1 line
2.1.0
Cheers, Andreas
Signature · 4 lines
Andreas Dilger Lustre Software Architect Intel High Performance Data Division