diff mbox series

[FFmpeg-devel,v2] avformat/protocols: fix discard const compile warning

Message ID 20210215065349.9873-1-nuomi2021@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2] avformat/protocols: fix discard const compile warning | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Nuo Mi Feb. 15, 2021, 6:53 a.m. UTC
we keep an index in *opaque instead of a pointer.
---
 libavformat/protocols.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 7df18fbb3b..530e78150d 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -111,17 +111,18 @@  const AVClass *ff_urlcontext_child_class_iterate(void **iter)
 
 const char *avio_enum_protocols(void **opaque, int output)
 {
-    const URLProtocol **p = *opaque;
+    const char* ret = NULL;
+    intptr_t i;
 
-    p = p ? p + 1 : url_protocols;
-    *opaque = p;
-    if (!*p) {
-        *opaque = NULL;
-        return NULL;
+    for (i = (intptr_t)*opaque; url_protocols[i]; i++) {
+        const URLProtocol *p = url_protocols[i];
+        if ((output && p->url_write) || (!output && p->url_read)) {
+            ret = p->name;
+            break;
+        }
     }
-    if ((output && (*p)->url_write) || (!output && (*p)->url_read))
-        return (*p)->name;
-    return avio_enum_protocols(opaque, output);
+    *opaque =  (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i);
+    return ret;
 }
 
 const AVClass *avio_protocol_get_class(const char *name)