[FFmpeg-devel] [PATCH] avutil/mem: add av_warn_unused_result
Michael Niedermayer
michael at niedermayer.cc
Fri Oct 16 17:37:41 CEST 2015
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
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151016/bb7a9133/attachment.sig>
More information about the ffmpeg-devel
mailing list