[FFmpeg-cvslog] avutil/attributes: add av_warn_unused_result
Ganesh Ajjanagadde
git at videolan.org
Mon Oct 5 20:05:12 CEST 2015
ffmpeg | branch: master | Ganesh Ajjanagadde <gajjanagadde at gmail.com> | Mon Oct 5 01:45:12 2015 -0400| [1d4af04adf99301e21d7364d72f5570f5219083a] | committer: Michael Niedermayer
avutil/attributes: add av_warn_unused_result
GCC 3.4 introduced an attribute warn_unused_result to warn when a programmer
discards the return value. Applying this judiciously across the codebase can help
in fixing a lot of problems. At a high level, functions which return error codes
should always be checked. More concretely, consider the functions ff_add_format
and the like in avfilter/formats.h. A quick examination shows that a large portion
of libavfilter fails to handle the associated errors, usually AVERROR(ENOMEM).
The above example was where I observed the utility of this, but it should be
useful in many places across the code base.
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1d4af04adf99301e21d7364d72f5570f5219083a
---
libavutil/attributes.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index 50e8eb3..5c6b9de 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -52,6 +52,12 @@
#endif
#endif
+#if AV_GCC_VERSION_AT_LEAST(3,4)
+# define av_warn_unused_result __attribute__((warn_unused_result))
+#else
+# define av_warn_unused_result
+#endif
+
#if AV_GCC_VERSION_AT_LEAST(3,1)
# define av_noinline __attribute__((noinline))
#elif defined(_MSC_VER)
More information about the ffmpeg-cvslog
mailing list