[FFmpeg-devel] [PATCH 1/7] avutil: add FF_BAIL_ON_OVERFLOW

Muhammad Faiz mfcc64 at gmail.com
Tue Dec 20 11:23:09 EET 2016


On 12/20/16, Andreas Cadhalpun <andreas.cadhalpun at googlemail.com> wrote:
> On 16.12.2016 07:36, Muhammad Faiz wrote:
>> On 12/16/16, Andreas Cadhalpun <andreas.cadhalpun at googlemail.com> wrote:
>>> Suggested-by: Rodger Combs <rodger.combs at gmail.com>
>>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
>>> ---
>>>  libavutil/common.h | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/libavutil/common.h b/libavutil/common.h
>>> index 8142b31..00b7504 100644
>>> --- a/libavutil/common.h
>>> +++ b/libavutil/common.h
>>> @@ -99,6 +99,8 @@
>>>  #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a=
>>> SWAP_tmp;}while(0)
>>>  #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
>>>
>>> +#define FF_BAIL_ON_OVERFLOW(ctx, x) if (x) {av_log(ctx, AV_LOG_ERROR,
>>> "Overflow check failed: " #x"\n"); return AVERROR_INVALIDDATA;}
>>
>> Where is the overflow check calculation?
>
> The parameter 'x' is the overflow check used in 'if (x)'.

Is it impossible to do something like
int ff_mul_check_overflow(int *result, int a, int b)
with AVERROR return code on overlow?
I suggest this is AVERROR(ERANGE)

>
>> What about functions that need clean up with goto before return?
>
> This is only needed rarely, e.g. in none of the patches I sent.
> It happens occasionally for the more common checks needed to
> validate codec parameters that I'm working on, but these can be
> handled on a case by case basis.
> The general macros are only for the common, trivial cases.

I think if macro for very specific case exists, the generic ones
should also exist,
especially generic error handling. Probably, I'm going to post that.

Thank's.

>
> Best regards,
> Andreas
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list