* [PATCH] net: wan: wanxl.c: Cleaning up declaration of a while loop
@ 2014-06-07 11:03 Rickard Strandqvist
2014-06-07 17:38 ` Krzysztof Halasa
0 siblings, 1 reply; 2+ messages in thread
From: Rickard Strandqvist @ 2014-06-07 11:03 UTC (permalink / raw)
To: Krzysztof Halasa, netdev; +Cc: Rickard Strandqvist, linux-kernel
Unusual declaration of a while loop.
However, believe you also want to make sure that the pointer is not NULL
This was partly found using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
drivers/net/wan/wanxl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index f76aa90..bde0943 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -196,7 +196,7 @@ static inline void wanxl_tx_intr(port_t *port)
static inline void wanxl_rx_intr(card_t *card)
{
desc_t *desc;
- while (desc = &card->status->rx_descs[card->rx_in],
+ while (desc = &card->status->rx_descs[card->rx_in] &&
desc->stat != PACKET_EMPTY) {
if ((desc->stat & PACKET_PORT_MASK) > card->n_ports)
pr_crit("%s: received packet for nonexistent port\n",
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: wan: wanxl.c: Cleaning up declaration of a while loop
2014-06-07 11:03 [PATCH] net: wan: wanxl.c: Cleaning up declaration of a while loop Rickard Strandqvist
@ 2014-06-07 17:38 ` Krzysztof Halasa
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Halasa @ 2014-06-07 17:38 UTC (permalink / raw)
To: Rickard Strandqvist; +Cc: netdev, linux-kernel
Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> writes:
> Unusual declaration of a while loop.
> However, believe you also want to make sure that the pointer is not NULL
Not really. The code is meant to do exactly what it currently does -
set variable desc and then check desc->stat.
All rx_descs are at this point already initialized and not NULL
(if desc was indeed NULL we better BUG*() or Oops on desc->stat access
instead of failing silently).
> --- a/drivers/net/wan/wanxl.c
> +++ b/drivers/net/wan/wanxl.c
> @@ -196,7 +196,7 @@ static inline void wanxl_tx_intr(port_t *port)
> static inline void wanxl_rx_intr(card_t *card)
> {
> desc_t *desc;
> - while (desc = &card->status->rx_descs[card->rx_in],
> + while (desc = &card->status->rx_descs[card->rx_in] &&
> desc->stat != PACKET_EMPTY) {
> if ((desc->stat & PACKET_PORT_MASK) > card->n_ports)
> pr_crit("%s: received packet for nonexistent port\n",
--
Krzysztof Halasa
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-07 17:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-07 11:03 [PATCH] net: wan: wanxl.c: Cleaning up declaration of a while loop Rickard Strandqvist
2014-06-07 17:38 ` Krzysztof Halasa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox