[FFmpeg-devel] [PATCH 2.c/3] libavformat/protocols.c: avio_enum_protocols(): Move the loop variables

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


The loop variables can now be moved into their respective
slots of the 'for(;;)' statement; this removes the need
for the 'done' label.

---
 libavformat/protocols.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 2aa302d08f..e3cde9ce02 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -95,19 +95,13 @@ const char *avio_enum_protocols(void **const opaque, const int output)
 {
     typedef const URLProtocol *const *Iterator;
     Iterator p = *opaque ? (Iterator)(*opaque) + 1 : url_protocols;
-    for(;;) {
-    if (*p) {
+    for(; *p; ++p) {
         if ((output && (*p)->url_write) || (!output && (*p)->url_read)) {
             *opaque = (void *)p;
             return (*p)->name;
         }
-    } else {
-        goto done;
-    }
-    ++p;
     }
 
-done:
     *opaque = NULL;
     return NULL;
 }
-- 
2.22.0



More information about the ffmpeg-devel mailing list