igb: fix compare_const_fl.cocci warnings
diff mbox

Message ID alpine.DEB.2.10.1512141558470.2591@hadrien
State Superseded
Delegated to: Jeff Kirsher
Headers show

Commit Message

Julia Lawall Dec. 14, 2015, 3 p.m. UTC
In both of these cases, it is more common to have the constant on the
right, in kernel code.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

CC: Gangfeng Huang <gangfeng.huang@ni.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>

---

 igb_main.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Brown, Aaron F Dec. 18, 2015, 2:58 a.m. UTC | #1
> From: Intel-wired-lan [intel-wired-lan-bounces@lists.osuosl.org] on behalf of Julia Lawall [julia.lawall@lip6.fr]
> Sent: Monday, December 14, 2015 7:00 AM
> To: Gangfeng Huang
> Cc: intel-wired-lan@lists.osuosl.org; kbuild-all@01.org
> Subject: [Intel-wired-lan] [PATCH] igb: fix compare_const_fl.cocci warnings
> 
> In both of these cases, it is more common to have the constant on the
> right, in kernel code.
> 
> Generated by: scripts/coccinelle/misc/compare_const_fl.cocci
> 
> CC: Gangfeng Huang <gangfeng.huang@ni.com>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
> 
> ---
> 
>  igb_main.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

And based on another patch I was looking at checkpatch agrees :)

It also suggests as a check that this could be written !adapter rather than NULL == adapter
------------------------------------------------------------------------------------------------
u1458:[1]/usr/src/kernels/next-queue> git format-patch 1b199aa -1 --stdout|./scripts/checkpatch.pl -
CHECK: Comparison to NULL could be written "!adapter"
#27: FILE: drivers/net/ethernet/intel/igb/igb_main.c:8276:
+	if (adapter == NULL) {

total: 0 errors, 0 warnings, 1 checks, 16 lines checked

Your patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
u1458:[1]/usr/src/kernels/next-queue> 
------------------------------------------------------------------------------------------------
But I don't have particularly strong feelings on that either way, so...

Tested-by: Aaron Brown <aaron.f.brown@intel.com>

Patch
diff mbox

--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -8209,7 +8209,7 @@  static int igb_change_mode(struct igb_ad
 	int err = 0;
 	int current_mode;

-	if (NULL == adapter) {
+	if (adapter == NULL) {
 		dev_err(&adapter->pdev->dev, "map to unbound device!\n");
 		return -ENOENT;
 	}
@@ -8272,7 +8272,7 @@  static ssize_t igb_set_qav_mode(struct d
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;

-	if (0 > kstrtoint(buf, 0, &request_mode))
+	if (kstrtoint(buf, 0, &request_mode) < 0)
 		return -EINVAL;

 	if (request_mode != 0 && request_mode != 1)