[Swan-dev] [PATCH libreswan v2] netlink: Silence negative shift coverity false warning

avivh at mellanox.com avivh at mellanox.com
Mon Sep 4 14:15:46 UTC 2017


From: Aviv Heller <avivh at mellanox.com>

Cast to unsigned before shift.

Signed-off-by: Aviv Heller <avivh at mellanox.com>
---
v1 -> v2:
    - Cast to unsigned instead of changing the type and values.
---
 programs/pluto/kernel_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/programs/pluto/kernel_netlink.c b/programs/pluto/kernel_netlink.c
index 0ed4e31..3c07b52 100644
--- a/programs/pluto/kernel_netlink.c
+++ b/programs/pluto/kernel_netlink.c
@@ -919,7 +919,7 @@ static enum iface_nic_offload netlink_detect_offload(const char *ifname)
 
 	/* Feature is supported by kernel. Query device features */
 	blocks = (netlink_esp_hw_offload + 31) / 32;
-	feature_bit = 1 << (netlink_esp_hw_offload % 31);
+	feature_bit = 1 << ((unsigned int)netlink_esp_hw_offload % 31);
 
 	cmd = alloc_bytes(sizeof(*cmd) + sizeof(cmd->features[0]) * blocks, "ethtool_gfeatures");
 	jam_str(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
-- 
1.8.3.1



More information about the Swan-dev mailing list