[FFmpeg-devel] [PATCH 2.4/3] libavformat/protocols.c: avio_enum_protocols(): Consolidate initialization of 'p'

Michael Witten mfwitten at gmail.com
Wed Aug 11 22:00:06 EEST 2021


Now that the label has been moved past the initial assignment of 'p',
it is possible to consolidate both the declaration and initialization.

A typedef is used to simplify the declaration of 'p', and to help the
reader understand what the purpose of 'p' is.

---
 libavformat/protocols.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 7e90cb067d..5e4bf5cbae 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -93,10 +93,8 @@ const AVClass *ff_urlcontext_child_class_iterate(void **iter)
 
 const char *avio_enum_protocols(void **const opaque, const int output)
 {
-    const URLProtocol *const *p;
-
-    p = *opaque;
-    p = p ? p + 1 : url_protocols;
+    typedef const URLProtocol *const *Iterator;
+    Iterator p = *opaque ? (Iterator)(*opaque) + 1 : url_protocols;
 iterate:
     *opaque = (void *)p;
     if (!*p) {
-- 
2.22.0



More information about the ffmpeg-devel mailing list