diff mbox series

[3/4] firmware: arm_scmi: Fix scmi_event_header fields typing

Message ID 20200708122248.52771-3-cristian.marussi@arm.com (mailing list archive)
State New, archived
Headers show
Series [1/4] firmware: arm_scmi: Remove zero-length array in SCMI Notifications | expand

Commit Message

Cristian Marussi July 8, 2020, 12:22 p.m. UTC
Drop size_t in favour of fixed size u32 for consistency and shuffle
around fields definitions to minimize implicit padding.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
 drivers/firmware/arm_scmi/notify.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Arnd Bergmann July 8, 2020, 8:38 p.m. UTC | #1
On Wed, Jul 8, 2020 at 2:24 PM Cristian Marussi
<cristian.marussi@arm.com> wrote:
>
> Drop size_t in favour of fixed size u32 for consistency and shuffle
> around fields definitions to minimize implicit padding.
>
> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>

As you still have implicit padding at the end, I'd either make
that explicit now, or leave the __packed attribute.

The payld_sz is not actually force to be misaligned with the
reordered layout, which is what's most important.

     Arnd
Cristian Marussi July 9, 2020, 8:24 a.m. UTC | #2
On Wed, Jul 08, 2020 at 10:38:08PM +0200, Arnd Bergmann wrote:
> On Wed, Jul 8, 2020 at 2:24 PM Cristian Marussi
> <cristian.marussi@arm.com> wrote:
> >
> > Drop size_t in favour of fixed size u32 for consistency and shuffle
> > around fields definitions to minimize implicit padding.
> >
> > Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
> 
> As you still have implicit padding at the end, I'd either make
> that explicit now, or leave the __packed attribute.

Do you mean expliciting that with a comment, right ? being the last member 'payld'
a flexible array must be the last in order to even compile.

I'm a bit confused anyway on how the trailing padding works on a struct like
this which ends with a flexible array definition, so I was expecting that the
trailing pads would have made no difference, given that it's used to basically
give some know layout to a blob of data via casting...

Thanks

Cristian

> 
> The payld_sz is not actually force to be misaligned with the
> reordered layout, which is what's most important.
> 
>      Arnd
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
index 752415367305..f441da28d91f 100644
--- a/drivers/firmware/arm_scmi/notify.c
+++ b/drivers/firmware/arm_scmi/notify.c
@@ -254,10 +254,10 @@  struct events_queue {
  * queueing it on the related &struct events_queue.
  */
 struct scmi_event_header {
-	u64	timestamp;
-	u8	evt_id;
-	size_t	payld_sz;
-	u8	payld[];
+	u64 timestamp;
+	u32 payld_sz;
+	u8 evt_id;
+	u8 payld[];
 };
 
 struct scmi_registered_event;