[FFmpeg-devel] [PATCH] avutil/mem: add av_warn_unused_result
Ganesh Ajjanagadde
gajjanag at mit.edu
Sat Oct 17 01:54:59 CEST 2015
On Fri, Oct 16, 2015 at 6:39 PM, Michael Niedermayer
<michael at niedermayer.cc> wrote:
> On Fri, Oct 16, 2015 at 05:21:57PM -0400, Ganesh Ajjanagadde wrote:
>> On Fri, Oct 16, 2015 at 5:11 PM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
>> > On Fri, Oct 16, 2015 at 11:37 AM, Michael Niedermayer
>> > <michael at niedermayer.cc> wrote:
>> >> On Thu, Oct 15, 2015 at 05:38:55PM -0400, Ganesh Ajjanagadde wrote:
>> >>> This adds av_warn_unused_result to functions whose return codes need to
>> >>> be checked.
>> >>>
>> >>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> >>> ---
>> >>> libavutil/mem.h | 3 +++
>> >>> 1 file changed, 3 insertions(+)
>> >>>
>> >>> diff --git a/libavutil/mem.h b/libavutil/mem.h
>> >>> index 2a1e36d..285697c 100644
>> >>> --- a/libavutil/mem.h
>> >>> +++ b/libavutil/mem.h
>> >>> @@ -144,6 +144,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
>> >>> * The situation is undefined according to POSIX and may crash with
>> >>> * some libc implementations.
>> >>> */
>> >>> +av_warn_unused_result
>> >>> int av_reallocp(void *ptr, size_t size);
>> >>>
>> >>> /**
>> >>> @@ -304,6 +305,7 @@ void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
>> >>> * @return >=0 on success, negative otherwise.
>> >>> * @see av_dynarray_add(), av_dynarray2_add()
>> >>> */
>> >>> +av_warn_unused_result
>> >>> int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem);
>> >>>
>> >>> /**
>> >>
>> >>> @@ -334,6 +336,7 @@ void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,
>> >>> * Multiply two size_t values checking for overflow.
>> >>> * @return 0 if success, AVERROR(EINVAL) if overflow.
>> >>> */
>> >>> +av_warn_unused_result
>> >>> static inline int av_size_mult(size_t a, size_t b, size_t *r)
>> >>
>> >> one doesnt strictly need to check the return value
>> >> one could use this as in
>> >> size_t r = MAX_WE_SUPPORT + 1;
>> >> av_size_mults(a,b,&r)
>> >> if (r > MAX_WE_SUPPORT)
>> >> fail
>> >
>> > Something went wrong, definitely did not intend for that particular
>> > one. Will update patch.
>>
>> Apologies for that stray addition, fixed locally. If everything else
>> is fine with you, will simply push.
>
> rest of this patch should be fine i think
Worst case build should not be broken, best case we have the correct
warning attributes. Pushed, thanks.
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> You can kill me, but you cannot change the truth.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list