2008-07-18 20:37:33

by Soumyadip Das Mahapatra

[permalink] [raw]
Subject: Surprising Code In sound/core/pcm_native.c In Recent Git Tree

Hello everyone!

When i was reading the code in sound/core/pcm_native.c in
recent git tree, i got stuck in line no 3258. It is something
like this
snd_assert(substream != NULL, goto out);

That (goto statement) surprised me for a while unless i came to
know snd_assert() is a macro (as expected!). Previous version
too had a return statement in it.

The point is that can we have a nicer code? Because this type
of code is sometimes __CONFUSING__.

Thanks :-)





2008-07-18 21:02:18

by Stefan Richter

[permalink] [raw]
Subject: Re: Surprising Code In sound/core/pcm_native.c In Recent Git Tree

Soumyadip Das Mahapatra wrote:
> When i was reading the code in sound/core/pcm_native.c in
> recent git tree, i got stuck in line no 3258. It is something
> like this
> snd_assert(substream != NULL, goto out);
>
> That (goto statement) surprised me for a while unless i came to
> know snd_assert() is a macro (as expected!). Previous version
> too had a return statement in it.
>
> The point is that can we have a nicer code? Because this type
> of code is sometimes __CONFUSING__.

Curious. The "goto out", "return -EIO" and friends are not compiled in
if CONFIG_SND_DEBUG is not set.

Why would anybody want a debug macro to exit from functions?

BTW, grep tells me there are 829 occurrences of snd_assert in linux 2.6.26.
--
Stefan Richter
-=====-==--- -=== =--=-
http://arcgraph.de/sr/