From: David Miller <davem@davemloft.net>
To: geert@linux-m68k.org
Cc: isubramanian@apm.com, kchudgar@apm.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drivers: net: xgene: Rewrite loop in xgene_enet_ecc_init()
Date: Wed, 22 Oct 2014 16:12:57 -0400 (EDT) [thread overview]
Message-ID: <20141022.161257.290251379136182774.davem@davemloft.net> (raw)
In-Reply-To: <CAMuHMdXJs=+SpB07t0a+LRWX_TGUnUmQi3P-aExFzmbm_j0fow@mail.gmail.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset=iso-8859-7, Size: 1368 bytes --]
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Wed, 22 Oct 2014 21:50:06 +0200
> On Wed, Oct 22, 2014 at 9:34 PM, David Miller <davem@davemloft.net> wrote:
>> From: Geert Uytterhoeven <geert@linux-m68k.org>
>> Date: Wed, 22 Oct 2014 09:39:41 +0200
>>
>>> drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c: In function ¡xgene_enet_ecc_init¢:
>>> drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c:126: warning: ¡data¢ may be used uninitialized in this function
>>>
>>> Depending on the arbitrary value on the stack, the loop may terminate
>>> too early, and cause a bogus -ENODEV failure.
>>>
>>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>> ---
>>> v2: Rewrite the loop instead of pre-initializing data.
>>
>> I hate to be a pest, but like the other patch of your's I think
>> a do { } while() works best here because the intent is clearly
>> to run the loop at least once, right?
>
> I wanted to avoid checking for "data != ~0U" twice: once to abort the loop,
> and once to check if a timeout happened.
Hmmm:
do {
usleep_range(...);
data = ...();
if (data == ~0)
return 0;
} while (++i < 10);
netdev_err(...);
return -ENODEV;
Why would you have to check data twice?
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next prev parent reply other threads:[~2014-10-22 20:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-22 7:39 Geert Uytterhoeven
2014-10-22 19:34 ` David Miller
2014-10-22 19:50 ` Geert Uytterhoeven
2014-10-22 20:12 ` David Miller [this message]
2014-10-23 7:05 ` Geert Uytterhoeven
2014-10-23 7:06 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141022.161257.290251379136182774.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=geert@linux-m68k.org \
--cc=isubramanian@apm.com \
--cc=kchudgar@apm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®