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 003B1473F9 for ; Thu, 7 Sep 2023 01:05:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 216B168C82E; Thu, 7 Sep 2023 04:05:09 +0300 (EEST) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2016.outbound.protection.outlook.com [40.92.59.16]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBDD668C751 for ; Thu, 7 Sep 2023 04:05:06 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nlUiqWLXGDZ02TxnijljiRFH85JEU23GrTGfIFpUkn47SfChSk6k5PgD17aVADJ+IpXgV3RTVl1enStpSFi3iEATJ0/amHKmERM04u2Ah81v7KA8eo4rHp0pPwVySJDvxRVnxZUOTvOhQOY3d05kXbHQeD3is0clwGzLSC1Qg1Ss2bvcvW9FrWKiFpvB6qev/mOWKIh9yGKYb39VWISwQuzFC+FyycVl93aVglZTjZNlxuB2TXiCMp/FZI9WSbi5qdBQW3uB7+Mqx8rnW+XphUvWu/6aXx1arFa7fIM1Rl6fAvS1pbfffqfiA0J0YFr4A6m6QcBjxwRXZh6kYbFBXg== 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=GC3okUBn1BzeuTE1tF3u67+ZoQsM8ws7Qf1d8OMF8DRXLHZwfaB8g28zaujY/AnmDM3eDV6ibt6D1winkQuqaOji/mugxSycMFy692qf1NELMsiGXphe7kzMgeFPQxR9ASXVWXrcyl0H5Kz3HdqfdH65XC/JVcKKbuswwmoG1ILZXJjc2Uz08jUMRXQ7hPY2+0B5U2NzVWgZH9rL5C2/72+BnkhoA0e4cWhOLuKbaejMhlMWE+TGFY2yqAcp040yDEOXQlbpwPt4lGewqsKl27le6OB8rsk7UakVg6hX6xbs5OFKlujSg0wrn0zkYu4H3lnvGu+dXEBIjwyVHW2s5Q== 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=IPEC8Wx7y8imtaSBjvxMWjMlZSmEisau1R9cPZMd6KZ4A0zW3PRvtOMCsgnjZnoZRjQc2eQyPDDNlPlMrYRxOryNYA2wAD7Uo6TN8re5UmD71T0LPu9+ib2xub8cfsibe/+zHTPAEumtan0OcXHc5tBKat86jedWL4Jv3dT3RCZsNojc+aCU6R3HiMn83ffAvRKMGg2aWxVQmVob/8gXzts7ixRZ9GUbeemEQdpoVegWmbp0utEOMjdnCHoe3nASrAFm3XKPuJfUNfasb42eBx9s4dHf44IGwQJsd/F4oD/wmN6Ylrw8K3NQGdyYxFAnMyNsjGGqNBavx/U5DmR/bw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by DU2P250MB0025.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:2b6::12) 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 01:05:05 +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 01:05:05 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Sep 2023 03:05:20 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [vXZElQw0ZPu6PROZ8NqvxV0a6pueyLfl] X-ClientProxiedBy: ZR0P278CA0096.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::11) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20230907010538.488975-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|DU2P250MB0025:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bf667c1-405d-4be3-320f-08dbaf3e788c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XmehqzJ/oI10/5VSJnauEbX28ikaVf5Qj0/syXvuQTwPscfHaPpsd8Et7w0KCBt/q5/MfTl9K5KbUMchT7ru0I/RT/65qPsqompOuUJL0j23pHJqi3Gh+RsagUX47HFfFrtlw0mq1Oebtsawutx+2uZ4OXXMf4OWrrNcInlDV84hlqNqPvQnEU/K8QzMtelokI9xmbviKrbsYIRPzSawdXoIodjugYdyfnIKBHxBlsA1sAgFTxnDaiiVCYdajZ0EGKp4fUYpW44xA+XxkrI3kqqQyV8J3KgI7//Ho4q0WYxL5+4rfSwQ33Y4pZAi8QP6mqdZe+x8i8r9Gly0I/yy2VWpbPGE94YDlM7vwz9tKdAEcUHi83GUlrFW+LsSgGH0zGzs0V7bd7mECi6BjQdg5yfPkczoRrskFVEE3qlbp/zaVWlZOR91hzOTOQv/KEG43sim5jfYAC+YVDt0qdOGUUrSEN7Svv6GQljv235HtwAKgdmRHtglNwSWiigivyYWV43jxHQKRPoNrZIy8mvoBj0tRt37jE246yYZZD4cBOIMqkBoxjz20cuCPlizMGvViE0Zqjz9ubu4tl642a4x8H5Q8Gr3yqF2pjVYBwPWfI/foUiy71BaXIJhj+/Rthaa X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dlnsG46VtcOOOVbo0rR+TjMdbGezBIrP9MIYuSNcbRcYbPhSJ85KPB9Hj30i?= =?us-ascii?Q?H2SDV75SbnGTYlEG4qXnPS4vdEQjqD5Uw5J0m0kIIDXUDEMeVwVxsN3zMaWu?= =?us-ascii?Q?A7ras0IHDOtAXAMnosfONWFrFqCQhQXVkAimDULaHEUfFEgyp+dA1s9HKH77?= =?us-ascii?Q?1MXwnCz48VrxBP/OzajtcR/UK4ObjZA3XxCx8a2AcDXDtbHpMZ0swpBuSkJo?= =?us-ascii?Q?im0qMIN7+My7FYXMaUw58+1AX+BaHWn+dw2+qMCjWbHHSNanHTOz9JSGO03+?= =?us-ascii?Q?0Q5icZXQr4FQaWG7FtZuWP/SaB4O1l9K5ps+tD3EupBNDZFA9Q37ukOMCU2V?= =?us-ascii?Q?A/YqBC1IMW0NvAxDcieLmtxUgmvpUlzRP8wmVdpGySCAPwbzyjpe73kOVhXI?= =?us-ascii?Q?h4ZPVg+6eSTzqM+dlh3eZ9etqSIT1WEw6yjqltylX4fDBTn6oTnCwvCrzuoU?= =?us-ascii?Q?2IhsYt8AO8jIAf/yFrqJzNtRo5iOk+o+phGi9B83D8D+/Y7JYVK2OhbqSHqz?= =?us-ascii?Q?5oqQw4QEADg2dZul7zQVGx2pQfP2xbZVHXYACm2FUSiO0CygddFbRz/aW0B8?= =?us-ascii?Q?w7cdn/0vzfQS1VW0vIr5XxvDWmxentvqvfUD8xzQDE3UJA09ycJ2XdPmG5Kh?= =?us-ascii?Q?YGXeMIn/dLXq7y0H9sUdIA9Ww+dSXV4rsFso8zBFMIehfpGHYx9i1gEUKuAc?= =?us-ascii?Q?inzdjpq+BS0r1oVM4rjK8EuKjLwwe42c9ivv7YgZEnb9H0G9fei0hFtpVXzE?= =?us-ascii?Q?aN1p9AagE2TxythEqh/iI+Ezy0vOuf222AT1pWH7akcb26LRGjuP3pnjEyen?= =?us-ascii?Q?GlM8wXt9v0UnIWdPzs9McufdRhM6zeSLbJu2v4JrxKASD9tIfZKhlqKSwnSd?= =?us-ascii?Q?Q5xpi/cKcBB3cRT5anerYwes1XyQCaXEv88+Mf8tBZ9hxv7svlAQAeFT6NRB?= =?us-ascii?Q?/x5Gky1bHEpT0hkYxFy+GrjMGPzkY80K5Fseu0L2Y2oOQfAn2GCENBBMYzp8?= =?us-ascii?Q?16HyIJWRTyDKYclJ1LG0qz7SCYEe+4RfbwnPO3gVevmNcFgIWWfRMRB7l0hK?= =?us-ascii?Q?IYqtdWYYS+mtpXrXQYDssxc6VCDTV0YsTOnTJL09gT3ZHeR1ZYNDDn7lf5sL?= =?us-ascii?Q?TauaMMWFDn3WzdDU8nfIhlQTrITKBinItoyV6BDLp1r2aI1kdTQ842XDs9UE?= =?us-ascii?Q?+csmrBu5qa5E1nDaXJBRpflVdPq05maeMcQYkcDH2dbHzpsIPNxnZL2As6+V?= =?us-ascii?Q?Pydr8j1ulbXesd8KyNyk?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bf667c1-405d-4be3-320f-08dbaf3e788c X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2023 01:05:05.0540 (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: DU2P250MB0025 Subject: [FFmpeg-devel] [PATCH v2 04/22] 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".