Commit a54ba346 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Jakub Kicinski

ch_ktls: fix build warning for ipv4-only config

When CONFIG_IPV6 is disabled, clang complains that a variable
is uninitialized for non-IPv4 data:

drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c:1046:6: error: variable 'cntrl1' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (tx_info->ip_family == AF_INET) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c:1059:2: note: uninitialized use occurs here
        cntrl1 |= T6_TXPKT_ETHHDR_LEN_V(maclen - ETH_HLEN) |
        ^~~~~~

Replace the preprocessor conditional with the corresponding C version,
and make the ipv4 case unconditional in this configuration to improve
readability and avoid the warning.

Fixes: 86716b51 ("ch_ktls: Update cheksum information")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20201203222641.964234-1-arnd@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 905b2032
...@@ -987,9 +987,7 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb, ...@@ -987,9 +987,7 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb,
struct fw_eth_tx_pkt_wr *wr; struct fw_eth_tx_pkt_wr *wr;
struct cpl_tx_pkt_core *cpl; struct cpl_tx_pkt_core *cpl;
u32 ctrl, iplen, maclen; u32 ctrl, iplen, maclen;
#if IS_ENABLED(CONFIG_IPV6)
struct ipv6hdr *ip6; struct ipv6hdr *ip6;
#endif
unsigned int ndesc; unsigned int ndesc;
struct tcphdr *tcp; struct tcphdr *tcp;
int len16, pktlen; int len16, pktlen;
...@@ -1043,17 +1041,15 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb, ...@@ -1043,17 +1041,15 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb,
cpl->len = htons(pktlen); cpl->len = htons(pktlen);
memcpy(buf, skb->data, pktlen); memcpy(buf, skb->data, pktlen);
if (tx_info->ip_family == AF_INET) { if (!IS_ENABLED(CONFIG_IPV6) || tx_info->ip_family == AF_INET) {
/* we need to correct ip header len */ /* we need to correct ip header len */
ip = (struct iphdr *)(buf + maclen); ip = (struct iphdr *)(buf + maclen);
ip->tot_len = htons(pktlen - maclen); ip->tot_len = htons(pktlen - maclen);
cntrl1 = TXPKT_CSUM_TYPE_V(TX_CSUM_TCPIP); cntrl1 = TXPKT_CSUM_TYPE_V(TX_CSUM_TCPIP);
#if IS_ENABLED(CONFIG_IPV6)
} else { } else {
ip6 = (struct ipv6hdr *)(buf + maclen); ip6 = (struct ipv6hdr *)(buf + maclen);
ip6->payload_len = htons(pktlen - maclen - iplen); ip6->payload_len = htons(pktlen - maclen - iplen);
cntrl1 = TXPKT_CSUM_TYPE_V(TX_CSUM_TCPIP6); cntrl1 = TXPKT_CSUM_TYPE_V(TX_CSUM_TCPIP6);
#endif
} }
cntrl1 |= T6_TXPKT_ETHHDR_LEN_V(maclen - ETH_HLEN) | cntrl1 |= T6_TXPKT_ETHHDR_LEN_V(maclen - ETH_HLEN) |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment