From patchwork Thu Nov 25 15:04:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31664 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp848139iob; Thu, 25 Nov 2021 07:05:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/Okp8mphb3xokUssYcQf/p75SYxtFkMZOXUCXlwiu+Phe4Db0Yo7J3lvUxVAXtAG5Huwk X-Received: by 2002:a17:907:728a:: with SMTP id dt10mr32110852ejc.526.1637852735712; Thu, 25 Nov 2021 07:05:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852735; cv=none; d=google.com; s=arc-20160816; b=O+SRX2WUGPuwtM4B/LWs11AUnhjsJHXYmXsz41FeIBkpAGzrVYf2lFQlYRGa8Aye2s +g1xHIqLIKNja9XwBiQgR1qCb4FzQjEjWFEC59TFuLbGOz+zQIksWSWbHEchZE/PKXSn kviewbHe6ANMOtqcsSuwfvTcCiFOhSsyFxbBQ0MqJmGCFhfu3NHGoZ74sgz2/DOp0HHE pzwUo0xFO0GrWm/xbuPyYE47sM7WgYDBqWAd48LNOGHZfupqrqdvvCFxgtVZM3iGMimd mhimFByOuliAiD4XXwlriN6Kb4zSPPgOnRfThgByr9ZjLoMwjDA+/Ksy6s/jQq3ldDeb 43FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=Unh+c8X6WdZU4GYrIvOqvtn+sSz8RRfZ8pRKCce6T38=; b=mM5Ncln6/l80Bi5JzmUSFAu3cjUAqwNefgVxtuusNqVoeyEC5uETzLoPadLfLyhC2i KbInaweFb8h3jT2NluiLGb8BqecX3ApLBqbCEKHmw7XpEJa8NqW4qq3naN0BUEB+Pf01 kA04CHLk9lLk2Ryd0xEXvFDTa3SS/Cf250+poR8aua03GZqgZsqrkLclegIbNk3rdBRR EVUeo+rkUuFZ8fRqiQc+bdHXlvQu+MHBCPjSmr34ByvfcB+x/yXhqMg1eiK9BH+hwVvF VirD+PkVzpQrPyMFWi/N9Iy33FgOtSXFZzxozBuWadAizhhtzMiKB9ejzcTvKeOh2m0D SgMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id do16si9384320ejc.357.2021.11.25.07.05.35; Thu, 25 Nov 2021 07:05:35 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 52ED468AE74; Thu, 25 Nov 2021 17:05:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1DDCF68ADC6 for ; Thu, 25 Nov 2021 17:05:09 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E8903240512 for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id jZZ4VzvpcmZA for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 7FD8F24017C for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id A71903A0631; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:52 +0100 Message-Id: <20211125150500.25040-1-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/9] lavd/jack: increase buffer size for snprintf() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 3daqFkjmHMB/ Maximum output size with a 32-bit int is 17 bytes, or 26 with a 64-bit int. Silences the following gcc 10 warning: src/libavdevice/jack.c: In function ‘audio_read_header’: src/libavdevice/jack.c:171:45: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] 171 | snprintf(str, sizeof(str), "input_%d", i + 1); | ^ src/libavdevice/jack.c:171:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 16 171 | snprintf(str, sizeof(str), "input_%d", i + 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- libavdevice/jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavdevice/jack.c b/libavdevice/jack.c index 31534134f3..0d5465e407 100644 --- a/libavdevice/jack.c +++ b/libavdevice/jack.c @@ -167,7 +167,7 @@ static int start_jack(AVFormatContext *context) /* Register JACK ports */ for (i = 0; i < self->nports; i++) { - char str[16]; + char str[32]; snprintf(str, sizeof(str), "input_%d", i + 1); self->ports[i] = jack_port_register(self->client, str, JACK_DEFAULT_AUDIO_TYPE, From patchwork Thu Nov 25 15:04:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31669 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp850642iob; Thu, 25 Nov 2021 07:07:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxCz/Shc6uSkXJoozWoAlXwqNevfyYZmlOrF/HcpfgsCZolqkyoPVgi+Tt4Huh1IvBOwEO X-Received: by 2002:a17:907:1687:: with SMTP id hc7mr31891861ejc.232.1637852829735; Thu, 25 Nov 2021 07:07:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852829; cv=none; d=google.com; s=arc-20160816; b=lWh/C1JuKRzhWBKoubWXKL5sgAGftZlNgBWL62UvxT1AdcaFweD8KibGnVoaEkDOal Vb2q+n9eRMQEF8vGwEnPah1uG5JfoWk7T41hoWEkNVjTuId0jTB8IIoDt+mJdEaU5b3H G48snYv+LphhTtlVcQMpaMBtATPJrkZLv79ycRD2ZfPISCY887F6Eeo0ahFihy7hIPjZ f441989OVtwGkt9qkzDuezFGPU+Jzk0KFujKqVjgSEVqEdTh8hDQ3fHSOb8DHfhUugJj sY/JeVxjSByW+RRzz7cLrNbyekqygq3mpoxfheURczwSd9l1vu2lGNtvhEZ+pxeoa6CG hUYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=2ZbX2rsY43eDoc0CSFJI5Aqt10I/mvf0vQu3LSGS8uI=; b=ZzpPycxzKoAHoJ7Ltw/SVqcsZjqCnSk2O0x6VcJ9ykOsAoWzEnl8g2vdBvdG59L0IB rHDeYDx0aAQoW3ctf3Yz9K04tANh8umLGcXhg9I85edJI1tOdezdu2aGTnw+LkNNWfUr La2dDglfryss3k7zLyNZTETLWgNuRPlPJtDR+peXzrW0W4GzlckEqs0cFJEjabLQSFeH u3fOQ/1W/KrT6SPISYOER9/jMSSgbXDbzk9Gcelrva9BCdTWeW9w+8Kr4TXga5GrS0rp I6o2maRt6MaXuNsG73IuJP7xYVWkiqw4VS4cVBmFLUzm0T+s54+vxnNPkP/5OEjOGnYl hYmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id du6si10170996ejc.161.2021.11.25.07.07.09; Thu, 25 Nov 2021 07:07:09 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 744BD68AEE9; Thu, 25 Nov 2021 17:05:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 56A0A68AE8D for ; Thu, 25 Nov 2021 17:05:14 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id C6E78240511 for ; Thu, 25 Nov 2021 16:05:11 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id VGpATOCQsDTU for ; Thu, 25 Nov 2021 16:05:07 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 831492404FE for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id A8F543A0398; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:53 +0100 Message-Id: <20211125150500.25040-2-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/9] lavf/v4l2: do not use a context variable unnecessarily 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: v2mUjdDXJphJ fd is local to the loop iteration, it is better to store it on stack than modify the context. --- libavdevice/v4l2.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index b5997fba33..777867db86 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -1033,16 +1033,17 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l return ret; } while ((entry = readdir(dir))) { + int fd = -1; char device_name[256]; if (!v4l2_is_v4l_dev(entry->d_name)) continue; snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); - if ((s->fd = device_open(ctx, device_name)) < 0) + if ((fd = device_open(ctx, device_name)) < 0) continue; - if (v4l2_ioctl(s->fd, VIDIOC_QUERYCAP, &cap) < 0) { + if (v4l2_ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0) { ret = AVERROR(errno); av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n", av_err2str(ret)); goto fail; @@ -1064,8 +1065,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l &device_list->nb_devices, device)) < 0) goto fail; - v4l2_close(s->fd); - s->fd = -1; + v4l2_close(fd); continue; fail: @@ -1074,9 +1074,8 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l av_freep(&device->device_description); av_freep(&device); } - if (s->fd >= 0) - v4l2_close(s->fd); - s->fd = -1; + if (fd >= 0) + v4l2_close(fd); break; } closedir(dir); From patchwork Thu Nov 25 15:04:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31662 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp848539iob; Thu, 25 Nov 2021 07:05:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJww/fEAeEiPLjBdA+mJ2bLOT5dk2YLpqLAMqauup6OxA54XxPebvycl69loOrIpg+wo7z7D X-Received: by 2002:a50:d741:: with SMTP id i1mr38798732edj.37.1637852749014; Thu, 25 Nov 2021 07:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852749; cv=none; d=google.com; s=arc-20160816; b=g3KeSuSYCSaKG+ccwWvhkmXb/sSYb52Zkt3Z5+heqsLk45WFJ4pdhIIxFwgx+CAMYh BBWnd6EP9tDm4nR3b31Mu3lyP5wUBRgkj+dNO+6WYe/pPa8p2QxIk54EAPnGib/oyuH7 G0VTg+JYZqqCKOPHGli2I2eICEZjV51PZ7Dy1XGvKfcsrfuozAKEIKJtjAKoPhKWHA1I 86WRVfbNIkm4TomN53QVcdjF53jnfpT2F6TeKQxw/de/Rb9ndXwb451oeBZRInwDNPO6 AaooM7YxvBm026oTTMeupVgwoyK04rt0vwU+O0Xq6q7NHbRgEbjVbLDYzlj4cnNbQZUF h1zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=NsYyC3gg120yoPU+dry4mGJ6JeDVgA/X+5MtON4ck6k=; b=kiuagxr6c8UqJgiq8sIsWmQ2kNRbrWb4FpMHEr9sKkk+AdAoTHP/Zxed5VccUzcqDz opHI6NEO4aPjH0yZLz6IYfwHZ6w7cRDuGAVQkRI26k6dZnAw5hI+h6FO18TYz+AOqR8o POG/kjC1jN40TLk7eJcBg2GcP/n22t298arVTdBnAerHmNLAxJwLERr1cFr33ySYSEei wmEOnMgpKbm6pgrWCgMH8OOm6JTAUcXtTRaBa/81dy3T1BbTwq9LFDKKB6lBuAInVqm5 Wxclk5HhJ3S48f/WXQauH3XmwfQuscrXn1aLpxvBvk2NrQGint4i7TzFm93wILx+zHz4 AkzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i1si7124402ejy.363.2021.11.25.07.05.48; Thu, 25 Nov 2021 07:05:48 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B2F6689981; Thu, 25 Nov 2021 17:05:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1FFB568ADDE for ; Thu, 25 Nov 2021 17:05:09 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 83B452400F5 for ; Thu, 25 Nov 2021 16:05:08 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 0fNQQmHZnYZ0 for ; Thu, 25 Nov 2021 16:05:08 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 8181424017E for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id AE2413A073E; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:54 +0100 Message-Id: <20211125150500.25040-3-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/9] lavd/v4l2: reduce variable scope 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xwh6oQeTI1pL device and cap are local to the loop iteration, there is no need for them to retain their values. Especially for device it may be dangerous, since it points to av_malloc'ed data. --- libavdevice/v4l2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 777867db86..c286b31c69 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -1019,8 +1019,6 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l struct video_data *s = ctx->priv_data; DIR *dir; struct dirent *entry; - AVDeviceInfo *device = NULL; - struct v4l2_capability cap; int ret = 0; if (!device_list) @@ -1033,6 +1031,8 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l return ret; } while ((entry = readdir(dir))) { + AVDeviceInfo *device = NULL; + struct v4l2_capability cap; int fd = -1; char device_name[256]; From patchwork Thu Nov 25 15:04:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31661 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp847702iob; Thu, 25 Nov 2021 07:05:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZ2hCg43yFT+VwvYzSvBqYnwvQ45+5B6Io/QM9yzZF+3KMr7r2eTsD2QcK4qiufHZScRmX X-Received: by 2002:a50:ec16:: with SMTP id g22mr38839114edr.214.1637852721498; Thu, 25 Nov 2021 07:05:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852721; cv=none; d=google.com; s=arc-20160816; b=ztiMdUoaffmcW0TKIbMXFN+WmaAKsNa80jcELc4wOxw2XWJHsjITwOzSqlLuTt/Wut 08y6XTGvizUduV150rfaqJCfW8l84yyO2ZYNNRJed94sxs8QhUgXIBjLOICSW4D/f9PL RrvtHHltUOr3+ZZNwEzICRpqmpy6GWLsAdP9UXFp8xDV3d5gQWlNiuFjNnMnwdei9QXh QsS1DLKUn3lEncLhI6SIY3LbHkc9uHsokHfH6x8xXGrtHH65b8z8ZKdat5/c3tAimnw0 DH6sIwmAuwwbdyJUpLiUQoRAeso0KmYOlDMzm5aRL/YCZXN6u5ClsS7xhgMPKpJ3hlHn prBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=X++LqHiOen1tIS+J31eEy8rQ8fMhT6ghNAXdYFYtZ3s=; b=Ns6lASFNNXBTOrgIoE34Q/pBMGAb/eGX//CE04S2WRDhRe7TT7z2l/6SPcDrSlsSTK dBCpP1kpLBAbvPhYUs6qTk/3C6ZJp9oh/KwcnpCIhyX8dFvqLUPfNyhJq+YBTC8yhTW6 eSvK0r4B1OCu2LhzzgPCyIhO/6eJHRjgczlAIEgcgIuDxDInbaSVq9bR6MBrzkDLE9Nw 0G4Librpt2DFtaqgfmgnI6JyL0nkFLWoJzvgXCcJBGFOqe+Vm5Q5ZFXam7CnjkNCe0lq dWgPdhnCu0W86lE0LYGr1xx5am8y72uYUu+CZa4oiKymzf0GvVExsu8Ujen+ylG7yWbv 0Wdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sh31si9829964ejc.257.2021.11.25.07.05.20; Thu, 25 Nov 2021 07:05:21 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB46268AE6D; Thu, 25 Nov 2021 17:05:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B11F689981 for ; Thu, 25 Nov 2021 17:05:09 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6D13E24017C for ; Thu, 25 Nov 2021 16:05:07 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id reNyTQ1C3sG5 for ; Thu, 25 Nov 2021 16:05:07 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 7D0AF24017A for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id B27193A0743; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:55 +0100 Message-Id: <20211125150500.25040-4-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/9] lavd/v4l2: detect device name truncation 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4Dd/77iCoAXZ Silences the following warning with gcc 10: src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’: src/libavdevice/v4l2.c:1042:64: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 251 [-Wformat-truncation=] 1042 | ret = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); | ^~ src/libavdevice/v4l2.c:1042:15: note: ‘snprintf’ output between 6 and 261 bytes into a destination of size 256 1042 | ret = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Previous patches intending to silence it have proposed increasing the buffer size, but doing that correctly seems to be tricky. Failing on truncation is simpler and just as effective (as excessively long device names are unlikely). --- libavdevice/v4l2.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index c286b31c69..80efc88203 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -1033,13 +1033,19 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l while ((entry = readdir(dir))) { AVDeviceInfo *device = NULL; struct v4l2_capability cap; - int fd = -1; + int fd = -1, size; char device_name[256]; if (!v4l2_is_v4l_dev(entry->d_name)) continue; - snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); + size = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); + if (size >= sizeof(device_name)) { + av_log(ctx, AV_LOG_ERROR, "Device name too long.\n"); + ret = AVERROR(ENOSYS); + goto fail; + } + if ((fd = device_open(ctx, device_name)) < 0) continue; From patchwork Thu Nov 25 15:04:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31667 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp848900iob; Thu, 25 Nov 2021 07:06:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqM2ranOImIepcoC2Kv+bIV2isW303XU094B6lI+4GX1O6D/AxgQ4mXKA02YlZS/LwJG7I X-Received: by 2002:a17:906:9744:: with SMTP id o4mr33079505ejy.322.1637852762997; Thu, 25 Nov 2021 07:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852762; cv=none; d=google.com; s=arc-20160816; b=x0t+Xbn09g/3ogPjcwgai54k4LXD/ijm+feFUq3JWtJBDLGgvhRuanbpCCNOLABwA6 4Ep4nDyUEr0WkvtVlvrarN45fv9/uZlLiRt1J0quZmHFoGKbePwKKxHuA3fT1AApaBBq b3uwrYfv/JrooahxIlN97dQuiE8ojDxqMLRv068UL6ZKdcm+GvDd/BISzaqFj19GGHwI CBKM4/FXmA4oU9XIPjQ0kcMUnkkomoO0+uhIryaFPOcjDS4OtPdE3GF5NkSGcPUb5Gk7 hVfBMZhYpFjXh9MDGVJ0j/HuGdPqKzf/IWDaWFO3x5iYqLC7hhrCHg00RrG2q1xCGCSh 1K6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=tpeOvHePyjNtU9MJX9OHLMotHggLMvq/H61xCcUSkwk=; b=C8W+qc8t4v5Iql5oojWfL2O0KjQGHpu5dNOP87s/Q5iQtK13bQJir5vPM+FgYvqTpr qqb+paD7EP3PHzo+addSydNvEgvLFZTH6N+EVN3DpE9ZA4M7/SEtltQw8hhHlDHGRJbz eDDWwHjruvyCkaOVYGY9SapcIII7uduRa1A40C+hGDHMN+5Q2isE9qcorLysrzdZh9QC Kux9HpM1F6gkes79lEm3ZVdU4o+fhOBnFq/nnkcIdYudnyxRXmq9KwA+EkjzEPCe1owE z9I8+YBQMB7ysTjdKD4cO0P8xqgGnL995smuPLmLLSuvJ60orXbOtVa+AwnGLFBR038K Sxqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gn8si7786645ejc.193.2021.11.25.07.06.02; Thu, 25 Nov 2021 07:06:02 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6CFC868AEA3; Thu, 25 Nov 2021 17:05:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 224D668ADE7 for ; Thu, 25 Nov 2021 17:05:09 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 15D3F24017A for ; Thu, 25 Nov 2021 16:05:08 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yhCZEFxByNsn for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 722CD2400F5 for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id B6B393A0746; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:56 +0100 Message-Id: <20211125150500.25040-5-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/9] lavfi/vf_subtitles: stop using deprecated ass_set_aspect_ratio() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: pYqdlbSPfFCK It has been deprecated in favor of ass_set_pixel_aspect() since version 0.11.0, roughly ~2014. Even Debian oldoldstable (stretch) has 0.13. --- configure | 2 +- libavfilter/vf_subtitles.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index d068b11073..4d9000567b 100755 --- a/configure +++ b/configure @@ -6430,7 +6430,7 @@ enabled libaribb24 && { check_pkg_config libaribb24 "aribb24 > 1.0.3" "ar die "ERROR: libaribb24 requires version higher than 1.0.3 or --enable-gpl."; } enabled lv2 && require_pkg_config lv2 lilv-0 "lilv/lilv.h" lilv_world_new enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 -enabled libass && require_pkg_config libass libass ass/ass.h ass_library_init +enabled libass && require_pkg_config libass "libass >= 0.11.0" ass/ass.h ass_library_init enabled libbluray && require_pkg_config libbluray libbluray libbluray/bluray.h bd_open enabled libbs2b && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 377160c72b..3fc4eeb63d 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -147,8 +147,8 @@ static int config_input(AVFilterLink *inlink) ass_set_frame_size (ass->renderer, inlink->w, inlink->h); if (ass->original_w && ass->original_h) - ass_set_aspect_ratio(ass->renderer, (double)inlink->w / inlink->h, - (double)ass->original_w / ass->original_h); + ass_set_pixel_aspect(ass->renderer, (double)inlink->w / inlink->h / + ((double)ass->original_w / ass->original_h)); if (ass->shaping != -1) ass_set_shaper(ass->renderer, ass->shaping); From patchwork Thu Nov 25 15:04:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31665 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp849254iob; Thu, 25 Nov 2021 07:06:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnp8e8uhoUfF5ZfIJUpfs4OYdktELBHK1ZaHucpohv+WNWGAOM0KKgNp+DSQREQhLbDH28 X-Received: by 2002:a17:907:7d86:: with SMTP id oz6mr31861666ejc.312.1637852777911; Thu, 25 Nov 2021 07:06:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852777; cv=none; d=google.com; s=arc-20160816; b=f2MVYhkiE+Db7BWX0mXpUbEW1qquRibzFKaGCPyYeSN3uEOGWiMxKV2XhKsN3qXeA1 D81UPaxFzHsfrpLbXX084VINcq00cT0wtwjhfTw6N6LySsc+qMAyQ56xwvN8tXZzPM7m kYV9aSyQ70RAEIu94Kr0s0Dtiggs39I8egSIl2onkifkTfoWG48Giac+qs3PY6e0euGn aAfQoU6QRrSH/cEC93gK/E6Yv6olBwv+LrN1yrUkHVNOuQZJNIrxIFf58s1HLlYj8B5E f2c5OGo2AyTpYTmRvSeGeZehf1TLkLRuqjJP77fF7mck1hX80uEjt9Qt0Wy7sJRn3ovr 8bIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=bg8Ner++alsyCZQan3UUrVeSB89IdDlQabw7hF712no=; b=ofZBRc/lyJy8dWxBXZaFsO5xIbh52dgnSfWXYylKPsMZIlB3gri4UWeO9bpoINK0Xv tiXwBcGP/KLANgx3ffZgs1n1H3XzLAAMVaeous48NX8liujb/bWFNYmK243eShTp2hAf O9igxfxZDWdAM3flRvGHsJ9zrvVBwEYBOtKmfYpwMFe768Kc3nP44CD1KmGLpm7pWba5 sDLm+nZgZWdyWh/wANoVJqAwKGgbsJIvlDPSuGilIscbxq6Go7INdBRy0IwqQxb1gfKa +bTo3rV7T57GoInp4dK8vEzHDW4xiEJ1yfj/rUsvEoMh8KaDYLH/aTs8dLPfWmMr3x8G PL+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r13si6497009edv.421.2021.11.25.07.06.16; Thu, 25 Nov 2021 07:06:17 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 834DB68AEA6; Thu, 25 Nov 2021 17:05:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A581968ADDE for ; Thu, 25 Nov 2021 17:05:09 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 420C224017E for ; Thu, 25 Nov 2021 16:05:09 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id kRXe1Bp8y98e for ; Thu, 25 Nov 2021 16:05:08 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id A7865240506 for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id BAE9F3A0769; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:57 +0100 Message-Id: <20211125150500.25040-6-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/9] lavf/ftp: check for truncation in snprintf 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: cGzQW7a54+8i Silences e.g. the following warning in gcc 10: src/libavformat/ftp.c: In function ‘ftp_move’: src/libavformat/ftp.c:1122:46: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4091 [-Wformat-truncation=] 1122 | snprintf(command, sizeof(command), "RNTO %s\r\n", path); | ^~ ~~~~ src/libavformat/ftp.c:1122:5: note: ‘snprintf’ output between 8 and 4103 bytes into a destination of size 4096 1122 | snprintf(command, sizeof(command), "RNTO %s\r\n", path); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- libavformat/ftp.c | 64 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/libavformat/ftp.c b/libavformat/ftp.c index 69caa7670c..883668b37b 100644 --- a/libavformat/ftp.c +++ b/libavformat/ftp.c @@ -250,13 +250,19 @@ static int ftp_auth(FTPContext *s) if (strpbrk(s->user, "\r\n")) return AVERROR(EINVAL); - snprintf(buf, sizeof(buf), "USER %s\r\n", s->user); + err = snprintf(buf, sizeof(buf), "USER %s\r\n", s->user); + if (err >= sizeof(buf)) + return AVERROR(ENOSYS); + err = ftp_send_command(s, buf, user_codes, NULL); if (err == 331) { if (s->password) { if (strpbrk(s->password, "\r\n")) return AVERROR(EINVAL); - snprintf(buf, sizeof(buf), "PASS %s\r\n", s->password); + err = snprintf(buf, sizeof(buf), "PASS %s\r\n", s->password); + if (err >= sizeof(buf)) + return AVERROR(ENOSYS); + err = ftp_send_command(s, buf, pass_codes, NULL); } else return AVERROR(EACCES); @@ -397,9 +403,13 @@ static int ftp_file_size(FTPContext *s) { char command[CONTROL_BUFFER_SIZE]; char *res = NULL; + int ret; static const int size_codes[] = {213, 0}; - snprintf(command, sizeof(command), "SIZE %s\r\n", s->path); + ret = snprintf(command, sizeof(command), "SIZE %s\r\n", s->path); + if (ret >= sizeof(command)) + return AVERROR(ENOSYS); + if (ftp_send_command(s, command, size_codes, &res) == 213 && res && strlen(res) > 4) { s->filesize = strtoll(&res[4], NULL, 10); } else { @@ -416,9 +426,12 @@ static int ftp_retrieve(FTPContext *s) { char command[CONTROL_BUFFER_SIZE]; static const int retr_codes[] = {150, 125, 0}; - int resp_code; + int resp_code, ret; + + ret = snprintf(command, sizeof(command), "RETR %s\r\n", s->path); + if (ret >= sizeof(command)) + return AVERROR(ENOSYS); - snprintf(command, sizeof(command), "RETR %s\r\n", s->path); resp_code = ftp_send_command(s, command, retr_codes, NULL); if (resp_code != 125 && resp_code != 150) return AVERROR(EIO); @@ -432,9 +445,12 @@ static int ftp_store(FTPContext *s) { char command[CONTROL_BUFFER_SIZE]; static const int stor_codes[] = {150, 125, 0}; - int resp_code; + int resp_code, ret; + + ret = snprintf(command, sizeof(command), "STOR %s\r\n", s->path); + if (ret >= sizeof(command)) + return AVERROR(ENOSYS); - snprintf(command, sizeof(command), "STOR %s\r\n", s->path); resp_code = ftp_send_command(s, command, stor_codes, NULL); if (resp_code != 125 && resp_code != 150) return AVERROR(EIO); @@ -471,8 +487,12 @@ static int ftp_set_dir(FTPContext *s) { static const int cwd_codes[] = {250, 550, 0}; /* 550 is incorrect code */ char command[MAX_URL_SIZE]; + int ret; + + ret = snprintf(command, sizeof(command), "CWD %s\r\n", s->path); + if (ret >= sizeof(command)) + return AVERROR(ENOSYS); - snprintf(command, sizeof(command), "CWD %s\r\n", s->path); if (ftp_send_command(s, command, cwd_codes, NULL) != 250) return AVERROR(EIO); return 0; @@ -1082,13 +1102,23 @@ static int ftp_delete(URLContext *h) if ((ret = ftp_connect(h, h->filename)) < 0) goto cleanup; - snprintf(command, sizeof(command), "DELE %s\r\n", s->path); + ret = snprintf(command, sizeof(command), "DELE %s\r\n", s->path); + if (ret >= sizeof(command)) { + ret = AVERROR(ENOSYS); + goto cleanup; + } + if (ftp_send_command(s, command, del_codes, NULL) == 250) { ret = 0; goto cleanup; } - snprintf(command, sizeof(command), "RMD %s\r\n", s->path); + ret = snprintf(command, sizeof(command), "RMD %s\r\n", s->path); + if (ret >= sizeof(command)) { + ret = AVERROR(ENOSYS); + goto cleanup; + } + if (ftp_send_command(s, command, rmd_codes, NULL) == 250) ret = 0; else @@ -1110,7 +1140,12 @@ static int ftp_move(URLContext *h_src, URLContext *h_dst) if ((ret = ftp_connect(h_src, h_src->filename)) < 0) goto cleanup; - snprintf(command, sizeof(command), "RNFR %s\r\n", s->path); + ret = snprintf(command, sizeof(command), "RNFR %s\r\n", s->path); + if (ret >= sizeof(command)) { + ret = AVERROR(ENOSYS); + goto cleanup; + } + if (ftp_send_command(s, command, rnfr_codes, NULL) != 350) { ret = AVERROR(EIO); goto cleanup; @@ -1119,7 +1154,12 @@ static int ftp_move(URLContext *h_src, URLContext *h_dst) av_url_split(0, 0, 0, 0, 0, 0, 0, path, sizeof(path), h_dst->filename); - snprintf(command, sizeof(command), "RNTO %s\r\n", path); + ret = snprintf(command, sizeof(command), "RNTO %s\r\n", path); + if (ret >= sizeof(command)) { + ret = AVERROR(ENOSYS); + goto cleanup; + } + if (ftp_send_command(s, command, rnto_codes, NULL) == 250) ret = 0; else From patchwork Thu Nov 25 15:04:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31668 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp849981iob; Thu, 25 Nov 2021 07:06:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTRB0K5PNWfhk6yNfr1J7/816Vo04ZDeVxdPR4SAAvETTnStKKpe89wb6G4Rqzya0b/HH3 X-Received: by 2002:a05:6402:2026:: with SMTP id ay6mr39765598edb.202.1637852806369; Thu, 25 Nov 2021 07:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852806; cv=none; d=google.com; s=arc-20160816; b=QeYIscgPmLJHom1MW8ZaqwUw49DAPxhXkB36gBceqWDG9BXCHAw8hMHwzEnhd8DwqU VmdDz/FY9tuZuuvrWp7OjZLZ08BfH5iXQZ2gNNBs8fOaF/WdhMNQKsyNRPGnsUy3XAGL wli9Py05g9hToZMhUbqQbY3FduT2ODbla1EO6t5rs7U5WK1brK+SFaDX5To4UFPhVCHx ezsofqSUD0py782xrMsWY3BCwEkxxD+M+Tf/IVFw13x6ZUjM1fXyjGl8fB05PWCmtT58 owqRUO8EFx9KofZF6n+pzbbyPQcEs38KjP4VwSL9NGerxWirfuUmbzKeqEmbUq6asBba FH0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=1QbOQrugnM8eOqLD2R/B1Y/MN8Vfe2v2nfKAjUZ5dcQ=; b=vW8A//16LGXxNiwT3zAPgnOyFomCFSpR/6VSb8SV6QSokPFT8Qgixsn3XR7IJPX1zb oxJgGusJF+ROHe1Ih1xjyoEaMjoCkScDmUcY3g19Il2QNHfBdUmBwu8n2sV3auRYURxY y6rUk2NvN0F91166Y+M78AaqKv7qkj7Hi8OTuW7uaZlWA/TFhdNyJEDoC2lsyHtzXVfY 1FwMLtm4Wvbw1KJGdYa3+9WvXQMBEZSVqLFL9DMKDql1EvCRyaUUkvd+OU79W3m/uEQH hgcQzphwCL6L0qqgtPcAnnDvHWcuS9DsIxZ+G087DbLXzSiK1MnJvDuehQTSL0KCDSlY Xbpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q18si8800984edd.564.2021.11.25.07.06.44; Thu, 25 Nov 2021 07:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6E2A168AECE; Thu, 25 Nov 2021 17:05:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 573CC68AE9B for ; Thu, 25 Nov 2021 17:05:14 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 51F9324050B for ; Thu, 25 Nov 2021 16:05:10 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id mXjdWljenfHB for ; Thu, 25 Nov 2021 16:05:09 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id AA70C240507 for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id BF1113A078F; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:58 +0100 Message-Id: <20211125150500.25040-7-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/9] lavf/img2enc: avoid a useless copy of the url 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: UnDIGcbVCRD4 img2enc keeps a private (and possibly truncated) copy of the url that is never modified. Just use AVFormatContext.url instead. --- libavformat/img2enc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 62202de9f4..44895490e6 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -36,7 +36,6 @@ typedef struct VideoMuxData { const AVClass *class; /**< Class for private options. */ int img_number; int split_planes; /**< use independent file for each Y, U, V plane */ - char path[1024]; char tmp[4][1024]; char target[4][1024]; int update; @@ -53,14 +52,12 @@ static int write_header(AVFormatContext *s) AVStream *st = s->streams[0]; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codecpar->format); - av_strlcpy(img->path, s->url, sizeof(img->path)); - if (st->codecpar->codec_id == AV_CODEC_ID_GIF) { img->muxer = "gif"; } else if (st->codecpar->codec_id == AV_CODEC_ID_FITS) { img->muxer = "fits"; } else if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) { - const char *str = strrchr(img->path, '.'); + const char *str = strrchr(s->url, '.'); img->split_planes = str && !av_strcasecmp(str + 1, "y") && s->nb_streams == 1 @@ -136,29 +133,29 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) AVDictionary *options = NULL; if (img->update) { - av_strlcpy(filename, img->path, sizeof(filename)); + av_strlcpy(filename, s->url, sizeof(filename)); } else if (img->use_strftime) { time_t now0; struct tm *tm, tmpbuf; time(&now0); tm = localtime_r(&now0, &tmpbuf); - if (!strftime(filename, sizeof(filename), img->path, tm)) { + if (!strftime(filename, sizeof(filename), s->url, tm)) { av_log(s, AV_LOG_ERROR, "Could not get frame filename with strftime\n"); return AVERROR(EINVAL); } } else if (img->frame_pts) { - if (av_get_frame_filename2(filename, sizeof(filename), img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { + if (av_get_frame_filename2(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames."); return AVERROR(EINVAL); } - } else if (av_get_frame_filename2(filename, sizeof(filename), img->path, + } else if (av_get_frame_filename2(filename, sizeof(filename), s->url, img->img_number, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 && img->img_number > 1) { av_log(s, AV_LOG_ERROR, "Could not get frame filename number %d from pattern '%s'. " "Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n", - img->img_number, img->path); + img->img_number, s->url); return AVERROR(EINVAL); } for (i = 0; i < 4; i++) { From patchwork Thu Nov 25 15:04:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31666 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp849608iob; Thu, 25 Nov 2021 07:06:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwO/XmJfXcLY9uNctHUR5Sy2RIb38H5FfKzxtnWmT4CRgCGzqEyVVoBAyQb6jRXn4lKNGV8 X-Received: by 2002:a17:906:e103:: with SMTP id gj3mr31968222ejb.456.1637852791708; Thu, 25 Nov 2021 07:06:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852791; cv=none; d=google.com; s=arc-20160816; b=GfgdYY366G0sPrdfIxZp/Gu0TY9HYISBV6ul1m6Q4Bus8aehDUVJwDjaM3D6g0ssbu yAnD+4IrxFGIi4emQuGVWRC1A3ijwK+3uKKrw54tlF+JMc3kt6wj/E0qOERGNAr1YHAz 4uGBB1Ocm39e9GnVQzFEZz8SRtuSqgLTgkWmZ6u2cKVfy98bJGNYgNgYMAGQ1ekamCsD W6FydIr/sPYAL2maI1h67cDJjrZyl+Dv5suXQaMCV6IMAfNoVFbu/hT7HXpiaJP/0jvw tdTCRFX/gXI28RY9JHQD+slKfv4AdFtJO/p4eR0UktHrcLRdWl3oTi9Ufsi0sfxV1A+a BRbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=aZincRK5jlLJD8uJYQBnVDBVs9FlefSf+jvV5047G4U=; b=QaBF1pmWWk37ndzdyZLHU/YCp6Me80Us1u/kERnXgBHWvP9f9G7P+xAMSgF8HSVvR5 T99b4yFYXCnMGJRhZ9KHVikg5ydhKrZxN7SCGZO4ztLDZaQnsodpCLi5LIG/fW1a4XuD pGVYw2nAy/SVajaEIBgnHSKDxvLlFqdktypCNa33WZ+KPOKLUC5TAXNbJu0Cv3iITfH+ NRWyg8tqHPz6lzhpm5X97czp1b/kUlcC49dxHHuZGUtCBpjOe08zj/p214rlz5Rp1keC Shwpzj91IS+REeS14KiJ2ue7cMX/F6rkGivJ+xEB5BjW6Yg5xKXM/KxyNxMSopEzcyl8 GN5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sa10si8027435ejc.689.2021.11.25.07.06.31; Thu, 25 Nov 2021 07:06:31 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 67E9168AEA0; Thu, 25 Nov 2021 17:05:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 56B6E68AE8E for ; Thu, 25 Nov 2021 17:05:14 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D458B240507 for ; Thu, 25 Nov 2021 16:05:10 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id rK32hS8mYNh5 for ; Thu, 25 Nov 2021 16:05:10 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id B3E61240511 for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id C39B73A0804; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:04:59 +0100 Message-Id: <20211125150500.25040-8-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/9] lavf/mov: drop a never-executed block 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zm2k7ZVFfDc/ MOVStts.duration is unsigned since 203b0e3561d. --- libavformat/mov.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 451cb78bbf..e85eeb0a0e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3965,16 +3965,6 @@ static void mov_build_index(MOVContext *mov, AVStream *st) current_offset += sample_size; stream_size += sample_size; - /* A negative sample duration is invalid based on the spec, - * but some samples need it to correct the DTS. */ - if (sc->stts_data[stts_index].duration < 0) { - av_log(mov->fc, AV_LOG_WARNING, - "Invalid SampleDelta %d in STTS, at %d st:%d\n", - sc->stts_data[stts_index].duration, stts_index, - st->index); - dts_correction += sc->stts_data[stts_index].duration - 1; - sc->stts_data[stts_index].duration = 1; - } current_dts += sc->stts_data[stts_index].duration; if (!dts_correction || current_dts + dts_correction > last_dts) { current_dts += dts_correction; From patchwork Thu Nov 25 15:05:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31663 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp850296iob; Thu, 25 Nov 2021 07:06:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpuS5hjYjp8GKmGvF0yL1iyyou6goMcg3DidmXpBWEPGNcPPayHRTa9UflpXcgAp7qgcsa X-Received: by 2002:a17:907:9612:: with SMTP id gb18mr32057611ejc.205.1637852817570; Thu, 25 Nov 2021 07:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637852817; cv=none; d=google.com; s=arc-20160816; b=GEs3PwIvpKfJN3N3TJxggRJY0FVOViWell0mGbnuuWdiGWQBmCzr7EOVEAziDvJiDz 3YhqaxvgnXh145LHtaJ/bCGUtRDrsHQaPHwpluVRV7nPadTmXLvF/q+aZ4N3ynytn1wZ mkwGKe0ZejufUcVheGCiwfLzxL5dS5hMRo0rydk0o9QQNuNR0f7eyf1ruRDYfK0vkRZ8 wRGqLih61YlncBUrmDB4DFQu7ubMiTOJaY2+y6Kmf2xgjLo6dkKhnBag2dZEAxIYTjqe 0lRNBYrCJbpi39AkkcOC2kA2XcVqeRZi9euMhkp5ci2QnFLqcEZwN7mssq9TxcRTuSjB zwGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=YD3T08sVqjo/j+qgS1wvRrbs2wobUNB0PUfTB2Ev1Ko=; b=BhwwDwmPr5WqvnAmSYRz73efPbpqTzTd1Ih6e/K9LTzPRhE7QS1gLDA2TR7DyRMdtG OS2J3Z+27q2sczPMDXBnqRU8p7blljE3dySKg1b1v9gv8tqNYN0TtyGTfMPuskl0cM/G kaijGMT965zeyWzlpoFKPSJTYC3GW52B4K7tRbFaVusggisHmJKRTzzpmp69ryGvVBWT 9EDMg2zZLNC3pMjSL0IE31SGYDM6cVfHvkcCFPCr+ijjFefCc4QQqoZ0hbp9srHtYxrh /KQXTmUQ4lCNqXg1+qd3yqhTnjRi3JS8+rcSBXgKJ8U55cljJlj+q7C3XFRRATgrt0xY NhUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u18si7032484eda.491.2021.11.25.07.06.57; Thu, 25 Nov 2021 07:06:57 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6361568AED3; Thu, 25 Nov 2021 17:05:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 58F6E68AEA0 for ; Thu, 25 Nov 2021 17:05:14 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id BF4D8240506 for ; Thu, 25 Nov 2021 16:05:09 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1jzElXWYkeQ3 for ; Thu, 25 Nov 2021 16:05:09 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id AB6A524050B for ; Thu, 25 Nov 2021 16:05:06 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id C845E3A09CE; Thu, 25 Nov 2021 16:05:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 16:05:00 +0100 Message-Id: <20211125150500.25040-9-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211125150500.25040-1-anton@khirnov.net> References: <20211125150500.25040-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 9/9] lavf/protocols: avoid discarding const in avio_enum_protocols() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nftOD58UNGCW Instead of storing the protocol pointer in the opaque iteration state, store just the index of the next protocol, similarly to how ff_urlcontext_child_class_iterate() works. --- libavformat/protocols.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/protocols.c b/libavformat/protocols.c index b108aa6c7e..948fae411f 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -93,17 +93,17 @@ const AVClass *ff_urlcontext_child_class_iterate(void **iter) const char *avio_enum_protocols(void **opaque, int output) { - const URLProtocol **p = *opaque; + uintptr_t i; - p = p ? p + 1 : url_protocols; - *opaque = p; - if (!*p) { - *opaque = NULL; - return NULL; + for (i = (uintptr_t)*opaque; url_protocols[i]; i++) { + const URLProtocol *p = url_protocols[i]; + if ((output && p->url_write) || (!output && p->url_read)) { + *opaque = (void*)(uintptr_t)(i + 1); + return p->name; + } } - if ((output && (*p)->url_write) || (!output && (*p)->url_read)) - return (*p)->name; - return avio_enum_protocols(opaque, output); + *opaque = NULL; + return NULL; } const AVClass *avio_protocol_get_class(const char *name)