igb: fix compare_const_fl.cocci warnings
Subsystems (2)
PATCH 1/1 igb: fix compare_const_fl.cocci warnings
Kernel code typically uses == NULL.
Generated by: scripts/coccinelle/misc/compare_const_fl.cocci
---
Alternatively, consider using !adapter.
igb_cdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/igb/igb_cdev.c +7 -7
@@ -92,7 +92,7 @@ static int igb_bind(struct file *file, v adapter = (struct igb_adapter *)file->private_data; -if (NULL == adapter) +if (adapter ==NULL )return -ENOENT ; mmap_size =pci_resource_len (adapter->pdev,0 );
@@ -119,7 +119,7 @@ static long igb_mapring(struct file *filreturn -EINVAL ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }
@@ -182,7 +182,7 @@ static long igb_mapbuf(struct file *filereturn -EINVAL ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }
@@ -246,7 +246,7 @@ static long igb_unmapring(struct file *freturn -EINVAL ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }
@@ -310,7 +310,7 @@ static long igb_unmapbuf(struct file *fireturn -EFAULT ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }
@@ -398,7 +398,7 @@ static int igb_close_file(struct inode * {struct igb_adapter *adapter = file->private_data; -if (NULL == adapter) +if (adapter ==NULL )return 0 ;mutex_lock (&adapter->cdev_mutex);
@@ -434,7 +434,7 @@ static int igb_mmap(struct file *file, sdma_addr_t pgoff = vma->vm_pgoff;dma_addr_t physaddr; -if (NULL == adapter) +if (adapter ==NULL )return -ENODEV ;if (pgoff ==0 )
PATCH 1/1 igb: fix compare_const_fl.cocci warnings
Actully, there is a more serious problem here, that there are a lot of potential dereferences of invalid pointers, via calls like:
dev_err(&adapter->pdev->dev, "map to unbound device!\n")
julia
Quoted 81 lines · Julia Lawall
Kernel code typically uses == NULL.
Generated by:
scripts/coccinelle/misc/compare_const_fl.cocciCC Gangfeng Huang <[email protected]>Signed-off-by Fengguang Wu <[email protected]>Signed-off-by Julia Lawall <[email protected]>---
Alternatively, consider using !adapter.
igb_cdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/intel/igb/igb_cdev.c +7
-7@@ -92,7 +92,7 @@ static int igb_bind(struct file *file, v adapter = (struct igb_adapter *)file->private_data; -if (NULL == adapter) +if (adapter ==NULL )return -ENOENT ; mmap_size =pci_resource_len (adapter->pdev,0 );@@ -119,7 +119,7 @@ static long igb_mapring(struct file *filreturn -EINVAL ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }@@ -182,7 +182,7 @@ static long igb_mapbuf(struct file *filereturn -EINVAL ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }@@ -246,7 +246,7 @@ static long igb_unmapring(struct file *freturn -EINVAL ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }@@ -310,7 +310,7 @@ static long igb_unmapbuf(struct file *fireturn -EFAULT ; adapter = file->private_data; -if (NULL == adapter) { +if (adapter ==NULL ) {dev_err (&adapter->pdev->dev,"map to unbound device!\n" );return -ENOENT ; }@@ -398,7 +398,7 @@ static int igb_close_file(struct inode * {struct igb_adapter *adapter = file->private_data; -if (NULL == adapter) +if (adapter ==NULL )return 0 ;mutex_lock (&adapter->cdev_mutex);@@ -434,7 +434,7 @@ static int igb_mmap(struct file *file, sdma_addr_t pgoff = vma->vm_pgoff;dma_addr_t physaddr; -if (NULL == adapter) +if (adapter ==NULL )return -ENODEV ;if (pgoff ==0 )
Brown
PATCH 1/1 igb: fix compare_const_fl.cocci warnings
Quoted 6 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Julia Lawall [julia.lawall at lip6.fr]
Sent: Wednesday, December 23, 2015 4:58 AM
To: Gangfeng Huang
Cc: intel-wired-lan at lists.osuosl.org; kbuild-all at 01.org
Subject: Re: [Intel-wired-lan] [PATCH] igb: fixcompare_const_fl.cocciwarnings
Quoted 6 lines
Actully, there is a more serious problem here, that there are a lot of potential dereferences of invalid pointers, via calls like:
dev_err(&adapter->pdev->dev, "map to unbound device!\n")julia
I don't see that this patch changes that, it still seems proper to apply this clean up.
Quoted 10 lines · Julia Lawall
Quoted 9 lines
Kernel code typically uses == NULL.
Generated by:
scripts/coccinelle/misc/compare_const_fl.cocciCC Gangfeng Huang <[email protected]>Signed-off-by Fengguang Wu <[email protected]>Signed-off-by Julia Lawall <[email protected]>
Quoted 6 lines
Quoted 6 lines
---
Alternatively, consider using !adapter.
igb_cdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
PATCH 1/1 igb: fix compare_const_fl.cocci warnings
Quoted 6 lines · Aaron F
Quoted 6 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Julia Lawall [julia.lawall at lip6.fr]
Sent: Wednesday, December 23, 2015 4:58 AM
To: Gangfeng Huang
Cc: intel-wired-lan at lists.osuosl.org; kbuild-all at 01.org
Subject: Re: [Intel-wired-lan] [PATCH] igb: fixcompare_const_fl.cocciwarnings
Quoted 8 lines
Quoted 6 lines
Actully, there is a more serious problem here, that there are a lot of potential dereferences of invalid pointers, via calls like:
dev_err(&adapter->pdev->dev, "map to unbound device!\n")julia
I don't see that this patch changes that, it still seems proper to apply this clean up.
No, the patch just does what the rule says, which is move the NULL to the other side.
julia
Quoted 19 lines
Quoted 11 lines · Julia Lawall
Quoted 9 lines
Kernel code typically uses == NULL.
Generated by:
scripts/coccinelle/misc/compare_const_fl.cocciCC Gangfeng Huang <[email protected]>Signed-off-by Fengguang Wu <[email protected]>Signed-off-by Julia Lawall <[email protected]>Quoted 6 lines
Quoted 6 lines
---
Alternatively, consider using !adapter.
igb_cdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)Tested-by Aaron Brown <[email protected]>