From patchwork Tue May 7 16:27:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13657461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFF8EC10F1A for ; Tue, 7 May 2024 16:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f3yeDfVVLSl/m0bWs74h/7JAfYLm8/zmpRKiqYsoxDY=; b=Y1Yv6/C8JZTfJ3 yJhfALmgjR1iIjAnB6QWIdPJY56dUaqBBGTXYuGi0tLsPWie5giuPkKIk0ODuLjgqtSWnvvlk+4dn 2igANQf53EyYRENyeNMBAw+akGBs7PzH93P87cacFxRsqATsKsxmnPN5nU1EqxAkFVDF0k3hObGpM qJhn1iZcJiZ67EokfDWjjmRT8d6h+CHcb/H2CFajuJxNEUe1FpWDXhdPcoSqYz54E5LZ3Jidk5Ptn EK+/gowgsNDfn/L1t6JHxElS/MUn+sLIgho6LMaBBGy75wNC2MBSAEnHIdaVNDZd6Y7nS1uDA8QYx /RL/upfkoYYTVTEqXA0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4NfC-0000000BxoZ-35ZN; Tue, 07 May 2024 16:27:34 +0000 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4New-0000000BxSb-0GBf for linux-arm-kernel@lists.infradead.org; Tue, 07 May 2024 16:27:21 +0000 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-43cff222427so13955371cf.3 for ; Tue, 07 May 2024 09:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715099231; x=1715704031; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XvJOy5lJ/u6e9yHF9m7H/WFxuEXKyxfgmG432+rwWPs=; b=ACft4qpOS6EKAHTW126lU12dRX43TGnDe0UD8vwm4K48yI8U/66g8e7M4JTE9mJWU2 Hjg5uO91qFWZgkfG37JAJJN6mnqEGzLAkK5b/RX5LCuk21Aea11guOSUbDBshaQSm15k 359FdXh6PGFheeQsbTHJr5yuoxjYTE0M9HV4w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715099231; x=1715704031; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XvJOy5lJ/u6e9yHF9m7H/WFxuEXKyxfgmG432+rwWPs=; b=hpy/GoEjEH8c3F3+0fUWxn9iB92VvsAojysv0YYFQfbD2CZY7nUAYQysYUFWtR2K15 s1M8OHyo5Xoztxe7XPnqQZMeyt0aI3DgU6KYiVX4ifhzlXZL4pq08HeaAZbxX/zlrIEQ 3e2cXGTUvRx7514nmXQ5rL2gd/aRNyxTKF3zqO5nLKLLEO5aZYemtf5ZNNSgKZi2+89J DnaYKjefY75j6Ps73Q9bymaXioQ1/G0oIsHIZc7Csg9OIvDnE/YHt9L6uEoXuybfwfKZ uvYsG50YLV+fiZ0lWcUtjOBt8qUQRpI6vqhCVQOLHItEu9VDByBGCrQp5PpPCnZry+Oe zjGw== X-Forwarded-Encrypted: i=1; AJvYcCUpl88p5p2XQjKE2GtsHDwjzeCbCJSFb6z9CltjQzGWYknkxjyGPXS9m5wouCdDiVNmzo1oanXefs668B43Siu59A1dPQ6uvmV5mXdCJV4mnBlbymU= X-Gm-Message-State: AOJu0YxKc7ZS2cgR/4Ajy2a97YUTbjNmu8dF1YkZYTn4r/nyEP1YO8ev DJSO87TfJDNKTbPoltCISsFZq8q7FPI7EZSTr94JdoaTw4yrC1wLuSehpj400Q== X-Google-Smtp-Source: AGHT+IH7wfmDbfR6Z2qEtq3pMk9IgeemDK1hAb5WzD+t2OuchV1RCwEJOdhdz0vPw5QCvormiuhN7g== X-Received: by 2002:ac8:5882:0:b0:437:c024:73f3 with SMTP id d75a77b69052e-43dbef87227mr2207121cf.44.1715099230572; Tue, 07 May 2024 09:27:10 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id hf23-20020a05622a609700b0043d1fc9b7d9sm4160597qtb.48.2024.05.07.09.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 09:27:09 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 07 May 2024 16:27:06 +0000 Subject: [PATCH v2 01/18] media: allegro: nal-hevc: Refactor nal_hevc_sub_layer_hrd_parameters MIME-Version: 1.0 Message-Id: <20240507-cocci-flexarray-v2-1-7aea262cf065@chromium.org> References: <20240507-cocci-flexarray-v2-0-7aea262cf065@chromium.org> In-Reply-To: <20240507-cocci-flexarray-v2-0-7aea262cf065@chromium.org> To: Michael Tretter , Pengutronix Kernel Team , Mauro Carvalho Chehab , Laurent Pinchart , Michal Simek , Andy Walls , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Hans Verkuil , Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240507_092718_272803_9697C48B X-CRM114-Status: GOOD ( 14.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace all the single elements arrays with the element itself. Pahole shows the same padding and alignment for x86 and arm in both situations. This fixes this cocci warning: drivers/media/platform/allegro-dvt/nal-hevc.h:102:14-22: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays) Signed-off-by: Ricardo Ribalda --- drivers/media/platform/allegro-dvt/allegro-core.c | 6 +++--- drivers/media/platform/allegro-dvt/nal-hevc.c | 11 +++-------- drivers/media/platform/allegro-dvt/nal-hevc.h | 6 +++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c index da61f9beb6b4..369bd88cc0ae 100644 --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c @@ -1852,14 +1852,14 @@ static ssize_t allegro_hevc_write_sps(struct allegro_channel *channel, hrd->dpb_output_delay_length_minus1 = 30; hrd->bit_rate_scale = ffs(channel->bitrate_peak) - 6; - hrd->vcl_hrd[0].bit_rate_value_minus1[0] = + hrd->vcl_hrd[0].bit_rate_value_minus1 = (channel->bitrate_peak >> (6 + hrd->bit_rate_scale)) - 1; cpb_size = v4l2_ctrl_g_ctrl(channel->mpeg_video_cpb_size) * 1000; hrd->cpb_size_scale = ffs(cpb_size) - 4; - hrd->vcl_hrd[0].cpb_size_value_minus1[0] = (cpb_size >> (4 + hrd->cpb_size_scale)) - 1; + hrd->vcl_hrd[0].cpb_size_value_minus1 = (cpb_size >> (4 + hrd->cpb_size_scale)) - 1; - hrd->vcl_hrd[0].cbr_flag[0] = !v4l2_ctrl_g_ctrl(channel->mpeg_video_frame_rc_enable); + hrd->vcl_hrd[0].cbr_flag = !v4l2_ctrl_g_ctrl(channel->mpeg_video_frame_rc_enable); size = nal_hevc_write_sps(&dev->plat_dev->dev, dest, n, sps); diff --git a/drivers/media/platform/allegro-dvt/nal-hevc.c b/drivers/media/platform/allegro-dvt/nal-hevc.c index 9cdf2756e0a3..575089522df5 100644 --- a/drivers/media/platform/allegro-dvt/nal-hevc.c +++ b/drivers/media/platform/allegro-dvt/nal-hevc.c @@ -210,14 +210,9 @@ static void nal_hevc_rbsp_vps(struct rbsp *rbsp, struct nal_hevc_vps *vps) static void nal_hevc_rbsp_sub_layer_hrd_parameters(struct rbsp *rbsp, struct nal_hevc_sub_layer_hrd_parameters *hrd) { - unsigned int i; - unsigned int cpb_cnt = 1; - - for (i = 0; i < cpb_cnt; i++) { - rbsp_uev(rbsp, &hrd->bit_rate_value_minus1[i]); - rbsp_uev(rbsp, &hrd->cpb_size_value_minus1[i]); - rbsp_bit(rbsp, &hrd->cbr_flag[i]); - } + rbsp_uev(rbsp, &hrd->bit_rate_value_minus1); + rbsp_uev(rbsp, &hrd->cpb_size_value_minus1); + rbsp_bit(rbsp, &hrd->cbr_flag); } static void nal_hevc_rbsp_hrd_parameters(struct rbsp *rbsp, diff --git a/drivers/media/platform/allegro-dvt/nal-hevc.h b/drivers/media/platform/allegro-dvt/nal-hevc.h index eb46f12aae80..afa7a9d7d654 100644 --- a/drivers/media/platform/allegro-dvt/nal-hevc.h +++ b/drivers/media/platform/allegro-dvt/nal-hevc.h @@ -97,9 +97,9 @@ struct nal_hevc_vps { }; struct nal_hevc_sub_layer_hrd_parameters { - unsigned int bit_rate_value_minus1[1]; - unsigned int cpb_size_value_minus1[1]; - unsigned int cbr_flag[1]; + unsigned int bit_rate_value_minus1; + unsigned int cpb_size_value_minus1; + unsigned int cbr_flag; }; struct nal_hevc_hrd_parameters {