Skip to contentSkip to conversation

igb: fix compare_const_fl.cocci warnings

PATCH New Julia Lawall 2 participants 2 messages Dec 14, 2015 – Dec 18, 2015

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

PATCH 1/1 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

---

 igb_main.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +2 -2
@@ -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)
#1 lore raw

PATCH 1/1 igb: fix compare_const_fl.cocci warnings

Quoted 11 lines

From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Julia Lawall [julia.lawall at lip6.fr]
Sent: Monday, December 14, 2015 7:00 AM
To: Gangfeng Huang
Cc: intel-wired-lan at lists.osuosl.org; kbuild-all at 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

Quoted 8 lines

---

 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...