[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <30530165-0ea9-4f02-9d8c-e8abc9eda5a7@kernel.org>
Date: Fri, 13 Sep 2024 12:23:38 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Cc: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
Karol Herbst <kherbst@...hat.com>, Lyude Paul <lyude@...hat.com>,
David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
dri-devel@...ts.freedesktop.org, nouveau@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] drm/nouveau: Avoid -Wflex-array-member-not-at-end
warning
Hi,
On 9/13/24 10:09 AM, Gustavo A. R. Silva wrote:
> Hi all,
>
> Friendly ping: who can take this, please? 🙂
Usually, that's me. But I thought you might want to send a v2 based on Kees'
comments?
- Danilo
>
> Thanks
> -Gustavo
>
> On 21/08/24 22:16, Gustavo A. R. Silva wrote:
>> Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of
>> a flexible structure where the size of the flexible-array member
>> is known at compile-time, and refactor the rest of the code,
>> accordingly.
>>
>> So, with this, fix the following warning:
>>
>> drivers/gpu/drm/nouveau/dispnv50/disp.c:779:47: warning: structure containing
>> a flexible array member is not at the end of another structure
>> [-Wflex-array-member-not-at-end]
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
>> ---
>> Â drivers/gpu/drm/nouveau/dispnv50/disp.c | 20 +++++++++-----------
>> Â 1 file changed, 9 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c
>> b/drivers/gpu/drm/nouveau/dispnv50/disp.c
>> index eed579a6c858..ddddc69640be 100644
>> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
>> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
>> @@ -774,11 +774,9 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct
>> nouveau_crtc *nv_crtc,
>> Â Â Â Â Â struct drm_hdmi_info *hdmi = &nv_connector->base.display_info.hdmi;
>> Â Â Â Â Â union hdmi_infoframe infoframe = { 0 };
>> Â Â Â Â Â const u8 rekey = 56; /* binary driver, and tegra, constant */
>> +Â Â Â DEFINE_RAW_FLEX(struct nvif_outp_infoframe_v0, args, data, 17);
>> +Â Â Â const u8 data_len = 17; /* same length as in DEFINE_RAW_FLEX above. */
>> Â Â Â Â Â u32 max_ac_packet;
>> -Â Â Â struct {
>> -Â Â Â Â Â Â Â struct nvif_outp_infoframe_v0 infoframe;
>> -Â Â Â Â Â Â Â u8 data[17];
>> -Â Â Â } args = { 0 };
>> Â Â Â Â Â int ret, size;
>>      max_ac_packet = mode->htotal - mode->hdisplay;
>> @@ -815,29 +813,29 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct
>> nouveau_crtc *nv_crtc,
>> Â Â Â Â Â Â Â Â Â return;
>> Â Â Â Â Â /* AVI InfoFrame. */
>> -Â Â Â args.infoframe.version = 0;
>> -Â Â Â args.infoframe.head = nv_crtc->index;
>> +Â Â Â args->version = 0;
>> +Â Â Â args->head = nv_crtc->index;
>> Â Â Â Â Â if (!drm_hdmi_avi_infoframe_from_display_mode(&infoframe.avi,
>> &nv_connector->base, mode)) {
>> Â Â Â Â Â Â Â Â Â drm_hdmi_avi_infoframe_quant_range(&infoframe.avi,
>> &nv_connector->base, mode,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â HDMI_QUANTIZATION_RANGE_FULL);
>> -Â Â Â Â Â Â Â size = hdmi_infoframe_pack(&infoframe, args.data,
>> ARRAY_SIZE(args.data));
>> +Â Â Â Â Â Â Â size = hdmi_infoframe_pack(&infoframe, args->data, data_len);
>> Â Â Â Â Â } else {
>> Â Â Â Â Â Â Â Â Â size = 0;
>> Â Â Â Â Â }
>> -Â Â Â nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_AVI,
>> &args.infoframe, size);
>> +Â Â Â nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_AVI, args,
>> size);
>> Â Â Â Â Â /* Vendor InfoFrame. */
>> -Â Â Â memset(&args.data, 0, sizeof(args.data));
>> +Â Â Â memset(args->data, 0, data_len);
>> Â Â Â Â Â if (!drm_hdmi_vendor_infoframe_from_display_mode(&infoframe.vendor.hdmi,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &nv_connector->base, mode))
>> -Â Â Â Â Â Â Â size = hdmi_infoframe_pack(&infoframe, args.data,
>> ARRAY_SIZE(args.data));
>> +Â Â Â Â Â Â Â size = hdmi_infoframe_pack(&infoframe, args->data, data_len);
>> Â Â Â Â Â else
>> Â Â Â Â Â Â Â Â Â size = 0;
>> -Â Â Â nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_VSI,
>> &args.infoframe, size);
>> +Â Â Â nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_VSI, args,
>> size);
>> Â Â Â Â Â nv_encoder->hdmi.enabled = true;
>> Â }
>
Powered by blists - more mailing lists