Skip to contentSkip to conversation

ethtool: Remove unnecessary null check in ethtool_rx_flow_rule_create

PATCH Applied Nathan Chancellor 3 participants 3 messages Feb 8, 2019 – Feb 9, 2019

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

PATCH 1/1 ethtool: Remove unnecessary null check in ethtool_rx_flow_rule_create

net/core/ethtool.c:3023:19: warning: address of array 'ext_m_spec->h_dest' will always evaluate to 'true' [-Wpointer-bool-conversion]

                if (ext_m_spec->h_dest) {
                ~~  ~~~~~~~~~~~~^~~~~~

h_dest is an array, it can't be null so remove this check.

Fixes eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")
---
 net/core/ethtool.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
net/core/ethtool.c +9 -11
index 0fbf39239b29..d2c47cdf25da 100644
@@ -3020,17 +3020,15 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
 		const struct ethtool_flow_ext *ext_h_spec = &fs->h_ext;
 		const struct ethtool_flow_ext *ext_m_spec = &fs->m_ext;
 
-		if (ext_m_spec->h_dest) {
-			memcpy(match->key.eth_addrs.dst, ext_h_spec->h_dest,
-			       ETH_ALEN);
-			memcpy(match->mask.eth_addrs.dst, ext_m_spec->h_dest,
-			       ETH_ALEN);
-
-			match->dissector.used_keys |=
-				BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS);
-			match->dissector.offset[FLOW_DISSECTOR_KEY_ETH_ADDRS] =
-				offsetof(struct ethtool_rx_flow_key, eth_addrs);
-		}
+		memcpy(match->key.eth_addrs.dst, ext_h_spec->h_dest,
+		       ETH_ALEN);
+		memcpy(match->mask.eth_addrs.dst, ext_m_spec->h_dest,
+		       ETH_ALEN);
+
+		match->dissector.used_keys |=
+			BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS);
+		match->dissector.offset[FLOW_DISSECTOR_KEY_ETH_ADDRS] =
+			offsetof(struct ethtool_rx_flow_key, eth_addrs);
 	}
 
 	act = &flow->rule->action.entries[0];
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Nathan Chancellor

net/core/ethtool.c:3023:19: warning: address of array 'ext_m_spec->h_dest' will always evaluate to 'true' [-Wpointer-bool-conversion]

                if (ext_m_spec->h_dest) {
                ~~  ~~~~~~~~~~~~^~~~~~

h_dest is an array, it can't be null so remove this check.

Fixes eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")

Thanks!

maintainer Applied
#2 lore raw
In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>
Date: Thu, 7 Feb 2019 21:46:53 -0700

Quoted 11 lines

net/core/ethtool.c:3023:19: warning: address of array 'ext_m_spec->h_dest' will always evaluate to 'true' [-Wpointer-bool-conversion]

                if (ext_m_spec->h_dest) {
                ~~  ~~~~~~~~~~~~^~~~~~

h_dest is an array, it can't be null so remove this check.

Fixes eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")

Applied.