[FFmpeg-devel] [RFC] av_assert

Alex Beregszaszi alex
Thu May 17 23:11:11 CEST 2007


Hi,

> > @@ -152,6 +153,14 @@
> >  
> >  #define av_abort()      do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
> >  
> > +
> > +#define av_assert(x) do { \
> > +     if (!(x)) { \
> > +        av_log(NULL, AV_LOG_ERROR, "Assertion '" #x "' failed in %s at %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \
> > +	abort(); \
> > +     } \
> > +} while(0)
> 
> i think the context should not be NULL but rather a argument from
> av_assert()

What about the same for av_abort()? Anyway, function name, file name and
line size gives you mostly the context.

> 
> id like to have 3 different classes of asserts
> 
> 1. av_slow_assert()
>     This assert occurs in non speed critical code and can stay enabled even
>     if we want as fast as possible libav*

> 2. av_fast_assert()
>     This assert occurs in speed critical code and should be disabled in non
>     debug builds

This type of assert should be used only when the failure of the
condition only introduces visual bugs / audio glitches, but never
crashes/undefined behaviour. Right?

> 3. av_security_assert()
>     This assert checks a security related assumtation and should always be
>     enabled unless the user explicitly disables such asserts

What about av_security_check/condition.

Anyway, if even 1 and 3 can be disabled explicitly, there is no
distinction between the two. Or do you want different error messages
printed?

--
Alex Beregszaszi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: av_assert.diff
Type: text/x-patch
Size: 1039 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070517/3b57329e/attachment.bin>



More information about the ffmpeg-devel mailing list