Skip to contentSkip to conversation

UPSTREAM:net: ethtool: fix compare_const_fl.cocci warnings

PATCH In review Julia Lawall 2 participants 2 messages Sep 2, 2020 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 UPSTREAM:net: ethtool: fix compare_const_fl.cocci warnings

From: kernel test robot <[email protected]>

Move constants to the right of binary operators.

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

Fixes 9dbdde22e919 ("UPSTREAM:net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
CC David Decotigny <[email protected]>

---

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-4.4
head:   718be6ad0e1b9e4a35f04c66a844a0d0298d7e35
commit: 9dbdde22e919de21d4297fedc79bee9fc8538154 [23/39] UPSTREAM:net: ethtool: add new ETHTOOL_xLINKSETTINGS API

:::::: branch date: 2 days ago
:::::: commit date: 4 days ago

This is probably a matter of personal preference, but to me it does look a little nicer after the change.

 ethtool.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
net/core/ethtool.c +6 -6
@@ -645,8 +645,8 @@ static int ethtool_get_link_ksettings(st
 			   sizeof(link_ksettings.base)))
 		return -EFAULT;
 
-	if (__ETHTOOL_LINK_MODE_MASK_NU32
-	    != link_ksettings.base.link_mode_masks_nwords) {
+	if (link_ksettings.base.link_mode_masks_nwords
+	    != __ETHTOOL_LINK_MODE_MASK_NU32) {
 		/* wrong link mode nbits requested */
 		memset(&link_ksettings, 0, sizeof(link_ksettings));
 		/* keep cmd field reset to 0 */
@@ -709,8 +709,8 @@ static int ethtool_set_link_ksettings(st
 			   sizeof(link_ksettings.base)))
 		return -EFAULT;
 
-	if (__ETHTOOL_LINK_MODE_MASK_NU32
-	    != link_ksettings.base.link_mode_masks_nwords)
+	if (link_ksettings.base.link_mode_masks_nwords
+	    != __ETHTOOL_LINK_MODE_MASK_NU32)
 		return -EINVAL;
 
 	/* copy the whole structure, now that we know it has expected
@@ -721,8 +721,8 @@ static int ethtool_set_link_ksettings(st
 		return err;
 
 	/* re-check nwords field, just in case */
-	if (__ETHTOOL_LINK_MODE_MASK_NU32
-	    != link_ksettings.base.link_mode_masks_nwords)
+	if (link_ksettings.base.link_mode_masks_nwords
+	    != __ETHTOOL_LINK_MODE_MASK_NU32)
 		return -EINVAL;
 
 	return dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
#1 lore raw
Quoted 13 lines · Julia Lawall

From: kernel test robot <[email protected]>

Move constants to the right of binary operators.

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

Fixes 9dbdde22e919 ("UPSTREAM:net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
CC David Decotigny <[email protected]>

---

Quoted 9 lines
tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-4.4
head:   718be6ad0e1b9e4a35f04c66a844a0d0298d7e35
commit: 9dbdde22e919de21d4297fedc79bee9fc8538154 [23/39] UPSTREAM:net: ethtool: add new ETHTOOL_xLINKSETTINGS API

:::::: branch date: 2 days ago
:::::: commit date: 4 days ago

This is probably a matter of personal preference, but to me it does look a little nicer after the change.

Yoda Programming I dislike too, but that kind of change should really be made in the upstream kernel (in net/ethtool/ioctl.c). No idea how Dave thinks about that.

Thanks,
Guenter

Quoted 38 lines
 ethtool.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
net/core/ethtool.c +6 -6
@@ -645,8 +645,8 @@ static int ethtool_get_link_ksettings(st
                           sizeof(link_ksettings.base)))
                return -EFAULT;
 
-       if (__ETHTOOL_LINK_MODE_MASK_NU32
-           != link_ksettings.base.link_mode_masks_nwords) {
+       if (link_ksettings.base.link_mode_masks_nwords
+           != __ETHTOOL_LINK_MODE_MASK_NU32) {
                /* wrong link mode nbits requested */
                memset(&link_ksettings, 0, sizeof(link_ksettings));
                /* keep cmd field reset to 0 */
@@ -709,8 +709,8 @@ static int ethtool_set_link_ksettings(st
                           sizeof(link_ksettings.base)))
                return -EFAULT;
 
-       if (__ETHTOOL_LINK_MODE_MASK_NU32
-           != link_ksettings.base.link_mode_masks_nwords)
+       if (link_ksettings.base.link_mode_masks_nwords
+           != __ETHTOOL_LINK_MODE_MASK_NU32)
                return -EINVAL;
 
        /* copy the whole structure, now that we know it has expected
@@ -721,8 +721,8 @@ static int ethtool_set_link_ksettings(st
                return err;
 
        /* re-check nwords field, just in case */
-       if (__ETHTOOL_LINK_MODE_MASK_NU32
-           != link_ksettings.base.link_mode_masks_nwords)
+       if (link_ksettings.base.link_mode_masks_nwords
+           != __ETHTOOL_LINK_MODE_MASK_NU32)
                return -EINVAL;
 
        return dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);