* [PATCH] net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx
@ 2019-08-12 3:13 Nathan Chancellor
2019-08-12 4:42 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2019-08-12 3:13 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, linux-kernel, clang-built-linux, Nathan Chancellor
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>
---
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 8479a440527b..12466a72cefc 100644
--- a/drivers/net/ethernet/toshiba/tc35815.c
+++ b/drivers/net/ethernet/toshiba/tc35815.c
@@ -1504,7 +1504,7 @@ tc35815_rx(struct net_device *dev, int limit)
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);
--
2.23.0.rc2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx
2019-08-12 3:13 [PATCH] net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx Nathan Chancellor
@ 2019-08-12 4:42 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-08-12 4:42 UTC (permalink / raw)
To: natechancellor; +Cc: netdev, linux-kernel, clang-built-linux
From: Nathan Chancellor <natechancellor@gmail.com>
Date: Sun, 11 Aug 2019 20:13:45 -0700
> 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>
Applied but I think clang is being rediculous.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-12 4:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 3:13 [PATCH] net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx Nathan Chancellor
2019-08-12 4:42 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).