From patchwork Sun Jan 15 22:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 40025 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1d43:b0:b8:6755:f97e with SMTP id cs3csp621902pzb; Sun, 15 Jan 2023 14:47:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXvFZyV5JCBxietw19ME7OmTqWQzmF1PrWhOiQR73P4zbuUPWCFVnPZfZRAC0U8H3c3yhMtJ X-Received: by 2002:a17:906:308b:b0:7ae:cda1:76d0 with SMTP id 11-20020a170906308b00b007aecda176d0mr70000050ejv.15.1673822878477; Sun, 15 Jan 2023 14:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673822878; cv=none; d=google.com; s=arc-20160816; b=pjNMJlG326jsMzaAnFe+mkuGytYHd6aXtLGToY54tFaQEsJXL9k5UqlE933r7Ttg6g CUX56jNAa2ZEWaIVVHaCsNiSFgY2yCOoI5XMs04I5RzoYuxmeVopP376jYaYgPo8eDv9 dmpRcHGJyRAr7ks0U67sy7zZkbaoTJ2lppzmBGa/TehGpUn/Xt2KUCn8at3LbNlIQU/3 eCcxyDTSCjERNqz/XOR96WC2S1dJiGdOUQcKoriIZXIh46AFNz0t9TAw75pxJsHTOcI1 C3KVdUjAE4cP+9QkD50xafTVoxOEElHHXXCTs3ynHHGngh1Tv3zPpdczweV89zVT7l/1 M1hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=4fxskw/bEByWLf8sl6837SKNAPEZVLK+oyJ8dhsAhdQ=; b=KGMbRbToZdWBVlppgmZXreGpYQlAC4J33z+p9t6PFu03oeAipa2jqo/CbOIj50i3+4 H6ulC+eBYGTLhoAOqQyUn5q8QPS7gsKnyExzJq3vSIN2K/JMPQQffMvpo+ZidcyUaO5m 5qBiq35NPde0XYbA+QETuvJlMKljKWdZpvh8gh+s/MWUhWrzknQOdZzTvTFVp/P8m6OG 8JN44IAcznLqvwI/Jriai5aBeiUz7nSh58gQGcYkZKzfEYEQ4B3KpkNAjBGZD0oJYZPp LNe7MXKsYZNcZfjtyGZUmqDkInOEV6wHb81ZHzp14wgpYFx4fc5E6iY4d0QoJA0OO3L0 cpBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=1BVqMiJ1; 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 d29-20020a056402401d00b0049dc6d14d61si4838029eda.63.2023.01.15.14.47.53; Sun, 15 Jan 2023 14:47:58 -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; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=1BVqMiJ1; 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 8FF3868BD05; Mon, 16 Jan 2023 00:47:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1829F68B3E1 for ; Mon, 16 Jan 2023 00:47:44 +0200 (EET) Received: by mail-lj1-f179.google.com with SMTP id o7so27970091ljj.8 for ; Sun, 15 Jan 2023 14:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8EqoNH0aSiyRCKXdyTtMI0FjqFcxdS3fAYDxqb+ZH4M=; b=1BVqMiJ1+72I0ipLha3AG5ziGcGCgEYfwcCj8FsWasALxWDojmHmI0Vl60EVS9uRWL W40s4wZeJHW7irBPHn5d6WGAzW1iNte/fln0kwWeRS3HGitQ/0n1kmHcHkO7RycD5YwI 2NgzJoBfLIfIK+IR9zC5eNNQyNJsBz51tV3/8fYoPARtl9ll6lHFgBaFrX780AVZV2eA HLeNvz9rPg4KmIZpJzNEhuejll1JaEILLXb4qpJzBaPKJH+1vlCEFeQmXJEoxz3lVfdP aDcts+24qRlTFMSwXBUB9q+1ulGGpnPTdnenZyaQbAKi0UEZ4d4Cn+vY3nz2Y9cLJh/A 2i8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8EqoNH0aSiyRCKXdyTtMI0FjqFcxdS3fAYDxqb+ZH4M=; b=NlOk5pynrfZMXk8a73Yfh1AO68OqdXTGRycnTF6RIGxoU6SB2tsJUKKa1h1uqsJPNi KHXMV5/UxPr9wV/k3fcgV9klLYtAS0UBcGALfUixMSIjzzFBAQ0yJN2V1rUOMGeWZQHM akCEcWrxdp3ORlQhPyhqojbOmQgDZmF2A4c87q6ajav3jAP9OfpBMQuU15A9jmQe5OiT 8vsn6WzRHyQDQQrobPkP4tw0E3Szd6n9rHP9vOz5LMyCtmX0lQcxS3XenWvWP+Wi7IZW koydw0mW7iqufd2AcMyI690jyHMZTTrZhRSPSOI0gQjio353rP82O0wnU/vZUu6seqJJ tf6w== X-Gm-Message-State: AFqh2kr5Q6N5BskUtrqodrJSg9ESyjJU7KYyDOFF46gKNoDMgVK+UkrU jAIhA/6KxscM4VvCVbuqdfjprmpUOJGc2bO6fTc= X-Received: by 2002:a2e:96c8:0:b0:287:301d:33c7 with SMTP id d8-20020a2e96c8000000b00287301d33c7mr6903692ljj.23.1673822863172; Sun, 15 Jan 2023 14:47:43 -0800 (PST) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id p22-20020a2eb7d6000000b0027ff0d95231sm3468769ljo.18.2023.01.15.14.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 14:47:42 -0800 (PST) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Jan 2023 00:47:41 +0200 Message-Id: <20230115224741.3446965-1-martin@martin.st> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavu/video_enc_params: Avoid relying on an undefined C construct 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: =?utf-8?q?Martin_Storsj=C3=B6?= , Anton Khirnov Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 3xYqb6YmcpDH The construct of using offsetof on a (potentially anonymous) struct defined within the offsetof expression, while supported by all current compilers, has been declared explicitly undefined by the C standards committee [1]. Current Clang git main got a patch [2] which changed this construct into a hard error. It seems like this will be softened into a warning [3] soon though, as it did break a fair number of projects. Nevertheless - in this particular case, it's trivial to fix the code not to rely on the construct that the standards committee has explicitly called out as undefined. [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm [2] https://github.com/llvm/llvm-project/commit/e327b52766ed497e4779f4e652b9ad237dfda8e6 [3] https://reviews.llvm.org/D133574#4053647 Signed-off-by: Martin Storsjö --- libavutil/video_enc_params.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c index 54bfed0ed9..33592dc128 100644 --- a/libavutil/video_enc_params.c +++ b/libavutil/video_enc_params.c @@ -27,11 +27,11 @@ AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type, unsigned int nb_blocks, size_t *out_size) { - const size_t blocks_offset = offsetof( - struct { - AVVideoEncParams p; - AVVideoBlockParams b; - }, b); + struct TestStruct { + AVVideoEncParams p; + AVVideoBlockParams b; + }; + const size_t blocks_offset = offsetof(struct TestStruct, b); size_t size = blocks_offset; AVVideoEncParams *par;