net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx [Linux 4.19.72]

This Linux kernel change "net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx" is included in the Linux 4.19.72 release. This change is authored by Nathan Chancellor <natechancellor [at] gmail.com> on Sun Aug 11 20:13:45 2019 -0700. The commit for this change in Linux stable tree is 7b7a115 (patch) which is from upstream commit 125b7e0. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 125b7e0.

net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx

[ Upstream commit 125b7e0949d4e72b15c2b1a1590f8cece985a918 ]

clang warns:

drivers/net/ethernet/toshiba/tc35815.c:1507:30: warning: use of logical
'&&' with constant operand [-Wconstant-logical-operand]
                        if (!HAVE_DMA_RXALIGN(lp) && NET_IP_ALIGN)
                                                  ^  ~~~~~~~~~~~~
drivers/net/ethernet/toshiba/tc35815.c:1507:30: note: use '&' for a
bitwise operation
                        if (!HAVE_DMA_RXALIGN(lp) && NET_IP_ALIGN)
                                                  ^~
                                                  &
drivers/net/ethernet/toshiba/tc35815.c:1507:30: note: remove constant to
silence this warning
                        if (!HAVE_DMA_RXALIGN(lp) && NET_IP_ALIGN)
                                                 ~^~~~~~~~~~~~~~~
1 warning generated.

Explicitly check that NET_IP_ALIGN is not zero, which matches how this
is checked in other parts of the tree. Because NET_IP_ALIGN is a build
time constant, this check will be constant folded away during
optimization.

Fixes: 82a9928db560 ("tc35815: Enable StripCRC feature")
Link: https://github.com/ClangBuiltLinux/linux/issues/608
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/toshiba/tc35815.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
index cce9c9e..9146068 100644
--- a/drivers/net/ethernet/toshiba/tc35815.c
+++ b/drivers/net/ethernet/toshiba/tc35815.c
@@ -1497,7 +1497,7 @@ static void tc35815_poll_controller(struct net_device *dev)
            pci_unmap_single(lp->pci_dev,
                     lp->rx_skbs[cur_bd].skb_dma,
                     RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
-           if (!HAVE_DMA_RXALIGN(lp) && NET_IP_ALIGN)
+           if (!HAVE_DMA_RXALIGN(lp) && NET_IP_ALIGN != 0)
                memmove(skb->data, skb->data - NET_IP_ALIGN,
                    pkt_len);
            data = skb_put(skb, pkt_len);

Leave a Reply

Your email address will not be published. Required fields are marked *