Skip to content

Commit

Permalink
net: nb8800: avoid uninitialized variable warning
Browse files Browse the repository at this point in the history
The nb8800_poll() function initializes the 'next' variable in the
loop looking for new input data. We know this will be called at
least once because 'budget' is a guaranteed to be a positive number
when we enter the function, but the compiler doesn't know that
and warns when the variable is used later:

drivers/net/ethernet/aurora/nb8800.c: In function 'nb8800_poll':
drivers/net/ethernet/aurora/nb8800.c:350:21: warning: 'next' may be used uninitialized in this function [-Wmaybe-uninitialized]

Changing the 'while() {}' loop to 'do {} while()' makes it obvious
to the compiler what is going on so it no longer warns.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Arnd Bergmann authored and David S. Miller committed Jan 30, 2016
1 parent 57e7c8c commit 8bdb290
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/aurora/nb8800.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static int nb8800_poll(struct napi_struct *napi, int budget)
nb8800_tx_done(dev);

again:
while (work < budget) {
do {
struct nb8800_rx_buf *rxb;
unsigned int len;

Expand Down Expand Up @@ -330,7 +330,7 @@ static int nb8800_poll(struct napi_struct *napi, int budget)
rxd->report = 0;
last = next;
work++;
}
} while (work < budget);

if (work) {
priv->rx_descs[last].desc.config |= DESC_EOC;
Expand Down

0 comments on commit 8bdb290

Please sign in to comment.