From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Clemens Ladisch <clemens@ladisch.de>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Arnd Bergmann <arnd@arndb.de>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH 2/2] ALSA: firewire-tascam: Use do { } while for loops executed at least once
Date: Mon, 15 May 2017 10:19:10 +0200 [thread overview]
Message-ID: <1494836350-28790-2-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1494836350-28790-1-git-send-email-geert@linux-m68k.org>
If a loop is intended to be executed at least once, it is better to use
"do { ... } while (...)" instead of "while (...) { ... }".
The former is easier to understand for the casual reviewer, and doesn't
require preinitializing the canary variable.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.
---
sound/firewire/tascam/tascam-stream.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c
index e433b92ac6904db5..4ea6845aae87fdef 100644
--- a/sound/firewire/tascam/tascam-stream.c
+++ b/sound/firewire/tascam/tascam-stream.c
@@ -80,17 +80,17 @@ static int set_clock(struct snd_tscm *tscm, unsigned int rate,
int snd_tscm_stream_get_rate(struct snd_tscm *tscm, unsigned int *rate)
{
- u32 data = 0x0;
unsigned int trials = 0;
+ u32 data;
int err;
- while (data == 0x0 && trials++ < 5) {
+ do {
err = get_clock(tscm, &data);
if (err < 0)
return err;
data = (data & 0xff000000) >> 24;
- }
+ } while (data == 0x0 && ++trials < 5);
/* Check base rate. */
if ((data & 0x0f) == 0x01)
--
2.7.4
next prev parent reply other threads:[~2017-05-15 8:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 8:19 [PATCH 1/2] ALSA: firewire-tascam: Fix infinite loop in snd_tscm_stream_get_rate() Geert Uytterhoeven
2017-05-15 8:19 ` Geert Uytterhoeven [this message]
2017-05-15 14:07 ` Takashi Sakamoto
2017-05-15 14:22 ` Geert Uytterhoeven
2017-05-15 14:40 ` Takashi Sakamoto
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=1494836350-28790-2-git-send-email-geert@linux-m68k.org \
--to=geert@linux-m68k.org \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=clemens@ladisch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=o-takashi@sakamocchi.jp \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/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®