From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 68512474D4 for ; Fri, 8 Sep 2023 20:43:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B60C868C864; Fri, 8 Sep 2023 23:43:26 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AA8AB68C837 for ; Fri, 8 Sep 2023 23:43:20 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E2A52E8FCE for ; Fri, 8 Sep 2023 22:38:52 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k0xtR5ZMh6KA for ; Fri, 8 Sep 2023 22:38:50 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 46169E7BD8 for ; Fri, 8 Sep 2023 22:38:50 +0200 (CEST) Date: Fri, 8 Sep 2023 22:38:50 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: Message-ID: <7cf28856-6611-ab55-256-f834ea24bc5@passwd.hu> References: MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 01/21] avformat/avio: Don't use incompatible function pointer type for call X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Thu, 7 Sep 2023, Andreas Rheinhardt wrote: > It is undefined behaviour even in cases where it works > (it works because it is only a const uint8_t* vs. uint8_t* difference). > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/avio.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/libavformat/avio.c b/libavformat/avio.c > index ab1c19a58d..d53da5cb0c 100644 > --- a/libavformat/avio.c > +++ b/libavformat/avio.c > @@ -354,10 +354,15 @@ fail: > } > > static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf, > + const uint8_t *cbuf, > int size, int size_min, > - int (*transfer_func)(URLContext *h, > - uint8_t *buf, > - int size)) > + int (*read_func)(URLContext *h, > + uint8_t *buf, > + int size), > + int (*write_func)(URLContext *h, > + const uint8_t *buf, > + int size), > + int read) These extra parameters are very ugly, can't we think of another way to properly support this? One idea is putting retry_transfer_wrapper in a template file and include it twice with proper defines-s for the read and write flavours. Regards, Marton > { > int ret, len; > int fast_retries = 5; > @@ -367,7 +372,8 @@ static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf, > while (len < size_min) { > if (ff_check_interrupt(&h->interrupt_callback)) > return AVERROR_EXIT; > - ret = transfer_func(h, buf + len, size - len); > + ret = read ? read_func (h, buf + len, size - len) > + : write_func(h, cbuf + len, size - len); > if (ret == AVERROR(EINTR)) > continue; > if (h->flags & AVIO_FLAG_NONBLOCK) > @@ -402,14 +408,16 @@ int ffurl_read(URLContext *h, unsigned char *buf, int size) > { > if (!(h->flags & AVIO_FLAG_READ)) > return AVERROR(EIO); > - return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read); > + return retry_transfer_wrapper(h, buf, NULL, size, 1, > + h->prot->url_read, NULL, 1); > } > > int ffurl_read_complete(URLContext *h, unsigned char *buf, int size) > { > if (!(h->flags & AVIO_FLAG_READ)) > return AVERROR(EIO); > - return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read); > + return retry_transfer_wrapper(h, buf, NULL, size, size, > + h->prot->url_read, NULL, 1); > } > > int ffurl_write(URLContext *h, const unsigned char *buf, int size) > @@ -420,9 +428,8 @@ int ffurl_write(URLContext *h, const unsigned char *buf, int size) > if (h->max_packet_size && size > h->max_packet_size) > return AVERROR(EIO); > > - return retry_transfer_wrapper(h, (unsigned char *)buf, size, size, > - (int (*)(struct URLContext *, uint8_t *, int)) > - h->prot->url_write); > + return retry_transfer_wrapper(h, NULL, buf, size, size, > + NULL, h->prot->url_write, 0); > } > > int64_t ffurl_seek(URLContext *h, int64_t pos, int whence) > -- > 2.34.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". > _______________________________________________ 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".