diff mbox

[2/3] net: fix netdev features shift for features bit > 31

Message ID 1366538974-4589-2-git-send-email-kaber@trash.net
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Patrick McHardy April 21, 2013, 10:09 a.m. UTC
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: In function 'qlcnic_set_netdev_features':
>> drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c:967:7: warning: large integer implicitly truncated to unsigned type [-Woverflow]

This should be fixed by explicitly using 1ULL for the shifted value.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 include/linux/netdev_features.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller April 21, 2013, 7:50 p.m. UTC | #1
From: Patrick McHardy <kaber@trash.net>
Date: Sun, 21 Apr 2013 12:09:33 +0200

>    drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: In function 'qlcnic_set_netdev_features':
>>> drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c:967:7: warning: large integer implicitly truncated to unsigned type [-Woverflow]
> 
> This should be fixed by explicitly using 1ULL for the shifted value.
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Patrick McHardy <kaber@trash.net>

The limitation is in the variable being assigned to, not the value
itself.

The "1" is already cast to a netdev_features_t by the macro
definition.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Patrick McHardy April 21, 2013, 8:43 p.m. UTC | #2
David Miller <davem@davemloft.net> schrieb:

>From: Patrick McHardy <kaber@trash.net>
>Date: Sun, 21 Apr 2013 12:09:33 +0200
>
>>    drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: In function
>'qlcnic_set_netdev_features':
>>>> drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c:967:7: warning:
>large integer implicitly truncated to unsigned type [-Woverflow]
>> 
>> This should be fixed by explicitly using 1ULL for the shifted value.
>> 
>> Reported-by: kbuild test robot <fengguang.wu@intel.com>
>> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
>The limitation is in the variable being assigned to, not the value
>itself.
>
>The "1" is already cast to a netdev_features_t by the macro
>definition.

Right, I thought the warning was caused by the shift not being able to represent the result. I'll fix it up properly later.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index cbaa027..f4d20f5 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -71,7 +71,7 @@  enum {
 };
 
 /* copy'n'paste compression ;) */
-#define __NETIF_F_BIT(bit)	((netdev_features_t)1 << (bit))
+#define __NETIF_F_BIT(bit)	((netdev_features_t)1ULL << (bit))
 #define __NETIF_F(name)		__NETIF_F_BIT(NETIF_F_##name##_BIT)
 
 #define NETIF_F_FCOE_CRC	__NETIF_F(FCOE_CRC)