diff mbox series

[FFmpeg-devel,2.3/3] libavformat/protocols.c: avio_enum_protocols(): Move 'iterate' label

Message ID f7edb6a1890a4689b4dd23a3a0d0ae32@gmail.com
State New
Headers show
Series None | expand

Commit Message

Michael Witten Aug. 11, 2021, 7 p.m. UTC
Upon iteration ('goto iterate;'), it is known that 'p' is non-zero,
so there is no point in doing the check; it is known that 'p' must
be incremented. Therefore, the 'iterate' label may be moved past
the ternary operator, provided that '++p;' is added just before
the 'goto', so as to perform the required incrementing.
---
 libavformat/protocols.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index b0aae66dab..7e90cb067d 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -95,9 +95,9 @@  const char *avio_enum_protocols(void **const opaque, const int output)
 {
     const URLProtocol *const *p;
 
-iterate:
     p = *opaque;
     p = p ? p + 1 : url_protocols;
+iterate:
     *opaque = (void *)p;
     if (!*p) {
         *opaque = NULL;
@@ -105,6 +105,7 @@  iterate:
     }
     if ((output && (*p)->url_write) || (!output && (*p)->url_read))
         return (*p)->name;
+    ++p;
     goto iterate;
 }