[alsa-devel] [PATCH] alsa-lib/tlv: fix handling of raw value ranges

Takashi Iwai tiwai at suse.de
Fri Mar 30 17:44:15 CEST 2012

At Fri, 30 Mar 2012 15:58:51 +0200 (CEST),
Benoît Thébaudeau wrote:
> Clemens Ladisch wrote:
> > I'll see if I can cobble together some TLV checking code ...
> Great.
> > > Because it's useless to wait until the end of the loop to return
> > > -EINVAL,
> > 
> > It is not necessary to optimize for error cases.
> It's not an optimization, but a simplification. Otherwise, pos would have to be
> tested again after the loop to differentiate the loop-skipped case from the
> at-least-one-loop-iteration cases to return either -EINVAL or the prev submax.

Unless it's really a hot path, such a micro-optimization doesn't give
much value.

Rather better to keep the standard style that makes people easier to
read the code.  A do-while loop with a large block is usually less
readable than a normal while loop.


More information about the Alsa-devel mailing list