Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 2/4] avformat/avio: Avoid function pointer casts
Date: Sat,  2 Mar 2024 20:51:57 +0100
Message-ID: <AS8P250MB074494B9D5806979C64CA8208F5D2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB07444E7A2DBA4FA55D5C0D5E8F5D2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

It is undefined behaviour to use a different type for a call
than the actual type of the function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/avio.c      | 5 ++---
 libavformat/librtmp.c   | 6 ++++--
 libavformat/mmsh.c      | 3 ++-
 libavformat/rtmpproto.c | 6 ++++--
 libavformat/url.h       | 4 ++--
 5 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 794ebd4bd8..1622a03d7f 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -450,9 +450,8 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
     (*s)->max_packet_size = max_packet_size;
     (*s)->min_packet_size = h->min_packet_size;
     if(h->prot) {
-        (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
-        (*s)->read_seek  =
-            (int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
+        (*s)->read_pause = h->prot->url_read_pause;
+        (*s)->read_seek  = h->prot->url_read_seek;
 
         if (h->prot->url_read_seek)
             (*s)->seekable |= AVIO_SEEKABLE_TIME;
diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index 5fa788fac8..bdd82ce15f 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -220,8 +220,9 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
     return ret;
 }
 
-static int rtmp_read_pause(URLContext *s, int pause)
+static int rtmp_read_pause(void *opaque, int pause)
 {
+    URLContext *s = opaque;
     LibRTMPContext *ctx = s->priv_data;
     RTMP *r = &ctx->rtmp;
 
@@ -230,9 +231,10 @@ static int rtmp_read_pause(URLContext *s, int pause)
     return 0;
 }
 
-static int64_t rtmp_read_seek(URLContext *s, int stream_index,
+static int64_t rtmp_read_seek(void *opaque, int stream_index,
                               int64_t timestamp, int flags)
 {
+    URLContext *s = opaque;
     LibRTMPContext *ctx = s->priv_data;
     RTMP *r = &ctx->rtmp;
 
diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c
index 672f4b3788..60113d61d2 100644
--- a/libavformat/mmsh.c
+++ b/libavformat/mmsh.c
@@ -371,9 +371,10 @@ static int mmsh_read(URLContext *h, uint8_t *buf, int size)
     return res;
 }
 
-static int64_t mmsh_read_seek(URLContext *h, int stream_index,
+static int64_t mmsh_read_seek(void *opaque, int stream_index,
                         int64_t timestamp, int flags)
 {
+    URLContext *h = opaque;
     MMSHContext *mmsh_old = h->priv_data;
     MMSHContext *mmsh     = av_mallocz(sizeof(*mmsh));
     int ret;
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 817c27b7ef..4b01b67d28 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2952,9 +2952,10 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
     return orig_size;
 }
 
-static int64_t rtmp_seek(URLContext *s, int stream_index, int64_t timestamp,
+static int64_t rtmp_seek(void *opaque, int stream_index, int64_t timestamp,
                          int flags)
 {
+    URLContext *s = opaque;
     RTMPContext *rt = s->priv_data;
     int ret;
     av_log(s, AV_LOG_DEBUG,
@@ -2972,8 +2973,9 @@ static int64_t rtmp_seek(URLContext *s, int stream_index, int64_t timestamp,
     return timestamp;
 }
 
-static int rtmp_pause(URLContext *s, int pause)
+static int rtmp_pause(void *opaque, int pause)
 {
+    URLContext *s = opaque;
     RTMPContext *rt = s->priv_data;
     int ret;
     av_log(s, AV_LOG_DEBUG, "Pause at timestamp %d\n",
diff --git a/libavformat/url.h b/libavformat/url.h
index 4f3bfb6d57..f62afedb78 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -76,8 +76,8 @@ typedef struct URLProtocol {
     int     (*url_write)(URLContext *h, const unsigned char *buf, int size);
     int64_t (*url_seek)( URLContext *h, int64_t pos, int whence);
     int     (*url_close)(URLContext *h);
-    int (*url_read_pause)(URLContext *h, int pause);
-    int64_t (*url_read_seek)(URLContext *h, int stream_index,
+    int (*url_read_pause)(void *urlcontext, int pause);
+    int64_t (*url_read_seek)(void *urlcontext, int stream_index,
                              int64_t timestamp, int flags);
     int (*url_get_file_handle)(URLContext *h);
     int (*url_get_multi_file_handle)(URLContext *h, int **handles,
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-03-02 19:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02 19:50 [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
2024-03-02 19:51 ` Andreas Rheinhardt [this message]
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 3/4] avformat/avio: Avoid indirection in ffio_fdopen() Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 4/4] avformat/avio: Avoid av_strdup(NULL) Andreas Rheinhardt
2024-03-04 16:12 ` [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB074494B9D5806979C64CA8208F5D2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git