Skip to contentSkip to conversation

ntb_hw_switchtec: fix logic error

PATCH RESEND In review Arnd Bergmann 2 participants 2 messages Jan 16, 2018 – Jan 18, 2018

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

PATCH RESEND 1/1 ntb_hw_switchtec: fix logic error

Newer gcc (version 7 and 8 presumably) warn about a statement mixing the << operator with logical and:

drivers/ntb/hw/mscc/ntb_hw_switchtec.c: In function 'switchtec_ntb_init_sndev':
drivers/ntb/hw/mscc/ntb_hw_switchtec.c:888:24: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]

My interpretation here is that the author must have intended a bitmask rather than a comparison, so I'm changing the '&&' to '&', which makes a lot more sense in the context.

Fixes 1b249475275d ("ntb_hw_switchtec: Allow using Switchtec NTB in multi-partition setups")

----
Originally sent on Dec 9, but this patch never got picked up

---
 drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
index bcd5b6fb3800..76acb8bba3f2 100644
@@ -885,7 +885,7 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
 		}
 
 		sndev->peer_partition = ffs(tpart_vec) - 1;
-		if (!(part_map && (1 << sndev->peer_partition))) {
+		if (!(part_map & (1 << sndev->peer_partition))) {
 			dev_err(&sndev->stdev->dev,
 				"ntb target partition is not NT partition\n");
 			return -ENODEV;
Signature · 1 line
2.9.0
maintainer
#1 lore raw
Quoted 10 lines · Arnd Bergmann

Newer gcc (version 7 and 8 presumably) warn about a statement mixing the << operator with logical and:

drivers/ntb/hw/mscc/ntb_hw_switchtec.c: In function 'switchtec_ntb_init_sndev':
drivers/ntb/hw/mscc/ntb_hw_switchtec.c:888:24: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]

My interpretation here is that the author must have intended a bitmask rather than a comparison, so I'm changing the '&&' to '&', which makes a lot more sense in the context.

Quoted 5 lines
Fixes 1b249475275d ("ntb_hw_switchtec: Allow using Switchtec NTB in multi-partition setups")

----
Originally sent on Dec 9, but this patch never got picked up

Sorry for missing the patch. Applied to ntb-next.

Thanks,
Jon

Quoted 20 lines
---
 drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
index bcd5b6fb3800..76acb8bba3f2 100644
@@ -885,7 +885,7 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
 		}
 
 		sndev->peer_partition = ffs(tpart_vec) - 1;
-		if (!(part_map && (1 << sndev->peer_partition))) {
+		if (!(part_map & (1 << sndev->peer_partition))) {
 			dev_err(&sndev->stdev->dev,
 				"ntb target partition is not NT partition\n");
 			return -ENODEV;
Signature · 1 line
2.9.0