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 60810473F9 for ; Thu, 7 Sep 2023 00:34:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1677768C7B5; Thu, 7 Sep 2023 03:34:35 +0300 (EEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2047.outbound.protection.outlook.com [40.92.90.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A7AB68C70F for ; Thu, 7 Sep 2023 03:34:28 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YcGizKDMlHp1sGTKFNJuvYGzrV5gr+mpA3OFJIKCKFPwL3kGupyb+VP4rCdQxgwiLX/zrY3EOlnPLWIc9sYHg/DCJIndU4caYD84PeerYS9sM9xBuOJXb3vy7Kre085FZpREweNRiZ1veaA7JRtn3W7j7yt0LAmqMELNQKKx/aDkS6Y3xUWRk4gjoaUR09cnOPlXoy/eTcT6emH2ow8DK29ml4UkEcyXgidsuofR+rJ+BhY2N4Vabo7ldcD/kFIjNN51yIXwrRe0CxuIt4xShh1xE5IuhKMwKDUtk2y4ztcSuzMSq9vr4MSWAGhOAqv+mt4TvCKbVuMwDxaLgxChvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6M7GN+F4hNvceC3kO+g/9K8tZJE1d2Hu8rmYAIUteEE=; b=LM1pkkCJF0sTguHpqIxN2pBqf0esWmh8arnOucfKxsVX9YiRUJVbPIHBB5BtPrRglJrBOH++zrQa993CECC0GlCPEjJc3LvkX6ZJLbMQYeeqPu7iuFnVEueJ6bHgI6mGZBQAlpLCySVPOWUSmI5CwOzLkRTQH36nTBZZ03EFBwppXQCB1jHrX3xZfcqT76BmZglnMEHT4268LmpauLY7Sb9fxGOhb46HGqljT08Y7AHptM5WqOj2E5JVl/QsnLCUBngHy1erTCKfgt80RGGMw6002hgp7WQ0bcir73RVjgsr1kVIXLE7VJU7PGDDx2Dfi5f/d+mbHact3FYcJmPVGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6M7GN+F4hNvceC3kO+g/9K8tZJE1d2Hu8rmYAIUteEE=; b=QZtp6YZEllfj1xXaeWv9zhjUNOVcPQsOOrj79ptRfaHCRxqUYYPt1a6dgUntoh2HG+rHk1qSxHEEYc6membNz+Hu1nrzsTWdW2fl2dMygHFIcgDWLK7hVYlUE7waiAypOm5W3OP6JoABGPP7I4uay1Omu8OL15TM3oLFXg11q14Cdi4K27t80sQ0CxKTgWqj4PpMXkKw0QGoE2QFxh2yDeXQGsEEWOFivsjeAqkNdKVkLA5Sd9iZW9rIQajl14BaPj3A8rEQDtFmX/PgtM767QZQhTXdmABeBMeo/SIp4ejtcpyEQ+Iiy+HKsm+O4UXsTrQlxqheQbP8GoJ6v3AU0g== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0353.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Thu, 7 Sep 2023 00:34:27 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa%3]) with mapi id 15.20.6745.034; Thu, 7 Sep 2023 00:34:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Sep 2023 02:32:21 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [PqsuBSanitE78SR/vRuKUHl5AT3PumUF] X-ClientProxiedBy: ZR2P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:47::7) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20230907003239.307330-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0353:EE_ X-MS-Office365-Filtering-Correlation-Id: fc8e21d6-751a-4ae8-f78a-08dbaf3a310c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XqcU0k0+DUZc/mfRekV/culLPuidH4887+nDa/O88v2oDLbkdnnjxMEEknvxr4pDcKSELTfU8OGCCWRXDEjgzi6iwbWjl9RdaeEBM86dZkZHJuHImNsOUsmNmoklo9hMBPxpnXFDfrRfmxEDLWRSK8VixYRPmAmycnjYmKM0RltX3bfUVPpuBm4sHBssD+4SloxKVOKqpVG/ureJyJ0PofqefUN9GhrrpGrxigAlDRLAlVeFRnafC+dr674ZTiALma6aN9yhz/8k3bNR1HlDYMF9CanjvgUdukeWmYx0CdbU2uOFEmCdiojosPWjEki9L/KCi+53jVts0gAzjDfmpaGk9kcSWl/Br46QRC+MV648C4CZ/HW1lBRb4Yg/H2yxQjqnn6DBpVPwholAuSlQw0WWSdTje42Iqa8iGS+MCf7XJ9Q7sBmL83qh5fBKA++m5CkNOkba1GT3rEA/z9LVXQkzrnuhHbl71oeIVc9O3mDmXdVBhk7iJCPPExrySSDfbmvvRBA6yhzNsMSeBNOl4LTm1OEHRD0ytHv0qd9JoJW3K9H34KMvHMxkFVTxthd1yo1YuxIJlq8KuIPDNhVTPW5m6HVH1Bb912aP/VP3pJSw7Q3rJim8hxfuMvACWj/m X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JDqYhXMZ8P3n7bKB9nTKTvSDkVdGSvl0jJ56KyODtq8P2oumPCokr53617lF?= =?us-ascii?Q?qjRjgDmY+ANV8qKjCJT5CpKGhIrPPT6UgrPgQFXePe6Fe9oBaXOyeF7xLx8H?= =?us-ascii?Q?ruETVtVh0Q2kPnHKzPOvIvefRkpkSRvu/2fsNFYOD0XJ2kjhDbHfq5nXoM4H?= =?us-ascii?Q?HgpSDlLDzQWuwM061l4hrCyUo0Qx/m8SaFyC1l7XqFE8zk5ZVD6XJHPlny0Z?= =?us-ascii?Q?jO+o6lydNpB/3dtSPrU3hOYgKQUBLquQfVtgyN8attauLWaDyDYIAKEMupaS?= =?us-ascii?Q?k8T7DMeQOkIIcGKLqKe6cTzG0rrWKkbpfQpzA4tSgu75diWzeKfqBl4yNgtu?= =?us-ascii?Q?XKozv25GNw7gAYPEr7fgZzvkK0lSg9b9xEcL7z49778x5N1qkN2Alg/w5xxC?= =?us-ascii?Q?Ng8eoB2JInztx+YMGsVq12EA6kUehEo8/lR1e81MWQTVoTCLh8fm4h+P2PB5?= =?us-ascii?Q?F+igdTQYMolR5ZUjxcAckdypaLK0dUhrHPy8mqc9TvqILHh0TIAjp0g73+1U?= =?us-ascii?Q?S7ECxaUgXY2RXhs121It0cODiG2Y+jWcH26+6X8L3FbWMYzIPsOo75Nyxfel?= =?us-ascii?Q?7VbKcCf5I/ohBvxQ1G2aiHd9qKdb8tHAPAMHYVqN7BGzEe5/YONdBh0s6Sv1?= =?us-ascii?Q?pav/UopHwLk7OfnqV2ZBXcDxYKmCDYvSXe6qdu4CDixc2mqCevxzomUMf4ze?= =?us-ascii?Q?TplqLF7kcLc1HQLq6Mncg2CbivgGWuL4e8njWD0XFF3YJNOeFOwMUrf4X+Ro?= =?us-ascii?Q?NC6ahsuPKyUUV+g41FTXudzGwOQlrptEBgX0g9TxSc3VRiNnCBn0y9E32HGY?= =?us-ascii?Q?pEu2W1H6CRbHoPMPKL46WiQlguZYHmAms+y7bDrNx0aY2c9sFFGKG1d2JOUu?= =?us-ascii?Q?VXhhNo9X+QhTIS2rc/+77j4aCQPhVo7Krgj7L2JvVUoN/uWPESg1HJyp/lem?= =?us-ascii?Q?3ZkdguysmVESGgSqGOKHJzKsUJ1BmInt+8SSFXmjONngD/63dWhiV52Ti+pW?= =?us-ascii?Q?u8TKxdfmNHDQFN3tcY959MwssMQqF4wiCLsIJlv3Bd6lE4EtmQoRC2ShPCwH?= =?us-ascii?Q?Zkuw/JukTlfvEKn9CI0TuPNO3KZpKqkPL1rvEEzgMdCuSpoKhQWdt707eLAR?= =?us-ascii?Q?YbekcjZI3c7MzHRZQJ/qlPUQCoecGo/AK8gCfE4uLhn4eOS4PegY3lJGKWZJ?= =?us-ascii?Q?7ph93tvGuWEOdCFmyOwdF1NBeuNR0A7ul+WkXbhgfrpoRAc0GuElRneL2ryK?= =?us-ascii?Q?/Lfm3c1jU/Dtw+aTG4UV?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc8e21d6-751a-4ae8-f78a-08dbaf3a310c X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2023 00:34:27.1407 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0353 Subject: [FFmpeg-devel] [PATCH 03/21] avformat/aviobuf: 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 Cc: Andreas Rheinhardt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: It is undefined behaviour even in cases where it works (it works because both are pointers). Instead change the functions involved to use the type expected by the AVIO-API and add inline wrappers for our internal callers. Signed-off-by: Andreas Rheinhardt --- libavformat/avio.c | 15 +++++++++++---- libavformat/aviobuf.c | 6 ++---- libavformat/url.h | 20 ++++++++++++++++---- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index d53da5cb0c..fd40f9ce43 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -404,8 +404,10 @@ static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf, return len; } -int ffurl_read(URLContext *h, unsigned char *buf, int size) +int ffurl_read2(void *urlcontext, uint8_t *buf, int size) { + URLContext *h = urlcontext; + if (!(h->flags & AVIO_FLAG_READ)) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, NULL, size, 1, @@ -420,8 +422,10 @@ int ffurl_read_complete(URLContext *h, unsigned char *buf, int size) h->prot->url_read, NULL, 1); } -int ffurl_write(URLContext *h, const unsigned char *buf, int size) +int ffurl_write2(void *urlcontext, uint8_t *buf, int size) { + URLContext *h = urlcontext; + if (!(h->flags & AVIO_FLAG_WRITE)) return AVERROR(EIO); /* avoid sending too big packets */ @@ -432,8 +436,9 @@ int ffurl_write(URLContext *h, const unsigned char *buf, int size) NULL, h->prot->url_write, 0); } -int64_t ffurl_seek(URLContext *h, int64_t pos, int whence) +int64_t ffurl_seek2(void *urlcontext, int64_t pos, int whence) { + URLContext *h = urlcontext; int64_t ret; if (!h->prot->url_seek) @@ -654,8 +659,10 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) return h->prot->url_get_multi_file_handle(h, handles, numhandles); } -int ffurl_get_short_seek(URLContext *h) +int ffurl_get_short_seek(void *urlcontext) { + URLContext *h = urlcontext; + if (!h || !h->prot || !h->prot->url_get_short_seek) return AVERROR(ENOSYS); return h->prot->url_get_short_seek(h); diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 029a9e966b..ad5827f216 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -976,9 +976,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) return AVERROR(ENOMEM); *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h, - (int (*)(void *, uint8_t *, int)) ffurl_read, - (int (*)(void *, uint8_t *, int)) ffurl_write, - (int64_t (*)(void *, int64_t, int))ffurl_seek); + ffurl_read2, ffurl_write2, ffurl_seek2); if (!*s) { av_freep(&buffer); return AVERROR(ENOMEM); @@ -1006,7 +1004,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) if (h->prot->url_read_seek) (*s)->seekable |= AVIO_SEEKABLE_TIME; } - ((FFIOContext*)(*s))->short_seek_get = (int (*)(void *))ffurl_get_short_seek; + ((FFIOContext*)(*s))->short_seek_get = ffurl_get_short_seek; (*s)->av_class = &ff_avio_class; return 0; } diff --git a/libavformat/url.h b/libavformat/url.h index 3cfe3ecc5c..bba1a9a1df 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -170,6 +170,7 @@ int ffurl_accept(URLContext *s, URLContext **c); */ int ffurl_handshake(URLContext *c); +int ffurl_read2(void *urlcontext, unsigned char *buf, int size); /** * Read up to size bytes from the resource accessed by h, and store * the read bytes in buf. @@ -179,7 +180,10 @@ int ffurl_handshake(URLContext *c); * indicates that it is not possible to read more from the accessed * resource (except if the value of the size argument is also zero). */ -int ffurl_read(URLContext *h, unsigned char *buf, int size); +static inline int ffurl_read(URLContext *h, uint8_t *buf, int size) +{ + return ffurl_read2(h, buf, size); +} /** * Read as many bytes as possible (up to size), calling the @@ -190,14 +194,19 @@ int ffurl_read(URLContext *h, unsigned char *buf, int size); */ int ffurl_read_complete(URLContext *h, unsigned char *buf, int size); +int ffurl_write2(void *urlcontext, uint8_t *buf, int size); /** * Write size bytes from buf to the resource accessed by h. * * @return the number of bytes actually written, or a negative value * corresponding to an AVERROR code in case of failure */ -int ffurl_write(URLContext *h, const unsigned char *buf, int size); +static inline int ffurl_write(URLContext *h, const uint8_t *buf, int size) +{ + return ffurl_write2(h, (uint8_t*)buf, size); +} +int64_t ffurl_seek2(void *urlcontext, int64_t pos, int whence); /** * Change the position that will be used by the next read/write * operation on the resource accessed by h. @@ -212,7 +221,10 @@ int ffurl_write(URLContext *h, const unsigned char *buf, int size); * the beginning of the file. You can use this feature together with * SEEK_CUR to read the current file position. */ -int64_t ffurl_seek(URLContext *h, int64_t pos, int whence); +static inline int64_t ffurl_seek(URLContext *h, int64_t pos, int whence) +{ + return ffurl_seek2(h, pos, whence); +} /** * Close the resource accessed by the URLContext h, and free the @@ -251,7 +263,7 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles); * * @return threshold (>0) on success or <=0 on error. */ -int ffurl_get_short_seek(URLContext *h); +int ffurl_get_short_seek(void *urlcontext); /** * Signal the URLContext that we are done reading or writing the stream. -- 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".