On 20.12.2016 10:23, Muhammad Faiz wrote: > On 12/20/16, Andreas Cadhalpun <andreas.cadhal...@googlemail.com> wrote: >> On 16.12.2016 07:36, Muhammad Faiz wrote: >>> On 12/16/16, Andreas Cadhalpun <andreas.cadhal...@googlemail.com> wrote: >>>> Suggested-by: Rodger Combs <rodger.co...@gmail.com> >>>> Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@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?
Not really, as the point of the macro is to do the error handling, which would be needed for a function. Also the function is not generic enough, as the type can be int64_t. And then using such a function would make the code rather less readable. > I suggest this is AVERROR(ERANGE) This seems like a better fit for the error type, so I've locally change the error in the macro to this. Best regards, Andreas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel