diff options
author | Takashi Iwai <tiwai@suse.de> | 2008-08-08 17:06:01 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-08-13 11:46:32 +0200 |
commit | 5ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89 (patch) | |
tree | 1947acad9b61fa80567fa1dd20c5b8c65ff8a46d /Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | |
parent | 3caf8c080ef0bd0ccdc20bb57b150b6e40a86fd3 (diff) | |
download | linux-5ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89.tar.gz linux-5ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89.tar.bz2 linux-5ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89.zip |
ALSA: Introduce snd_BUG_ON() macro
Introduced snd_BUG_ON() macro as a replacement of snd_assert() macro.
snd_assert() is pretty ugly as it has the control flow in its argument.
OTOH, snd_BUG_ON() behaves like a normal conditional, thus it's much
easier to read the flow.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl')
-rw-r--r-- | Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index e13c4e67029f..df699e4323ef 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -6173,6 +6173,47 @@ struct _snd_pcm_runtime { When no debug flag is set, this macro is ignored. </para> </section> + + <section id="useful-functions-snd-bug-on"> + <title><function>snd_BUG_ON()</function></title> + <para> + <function>snd_BUG_ON()</function> macro is similar with + <function>WARN_ON()</function> macro. For example, + + <informalexample> + <programlisting> +<![CDATA[ + snd_BUG_ON(!pointer); +]]> + </programlisting> + </informalexample> + + or it can be used as the condition, + <informalexample> + <programlisting> +<![CDATA[ + if (snd_BUG_ON(non_zero_is_bug)) + return -EINVAL; +]]> + </programlisting> + </informalexample> + + </para> + + <para> + The macro takes an conditional expression to evaluate. + When <constant>CONFIG_SND_DEBUG</constant>, is set, the + expression is actually evaluated. If it's non-zero, it shows + the warning message such as + <computeroutput>BUG? (xxx)</computeroutput> + normally followed by stack trace. It returns the evaluated + value. + When no <constant>CONFIG_SND_DEBUG</constant> is set, this + macro always returns zero. + </para> + + </section> + </chapter> |