media: Fix missing warnings for llvm am32
cover media: Fix missing warnings for llvm am32
When we were building the project with llvm for arm32 a number of warnings where shown.
This is passing the ABI check:
https://gitlab.freedesktop.org/linux-media/media-staging/-/jobs/57432144
---
Ricardo Ribalda (3):
media: dvb: as102-fe: Fix as10x_register_addr packing
media: dvb: Fix dtvs_stats packing.
media: videodev2: Fix v4l2_ext-control packing.
drivers/media/dvb-frontends/as102_fe_types.h | 2 +- include/uapi/linux/dvb/frontend.h | 2 +- include/uapi/linux/videodev2.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
---
base-commit: d8c9a6e204f1466d228428174ce6d40ccdfb583e
change-id: 20240410-pack-e719cdfa0a6f
Best regards,
Signature · 1 line
Ricardo Ribalda <[email protected]>
PATCH 1/3 media: dvb: as102-fe: Fix as10x_register_addr packing
This structure is embedded in multiple other structures that are packed, which conflicts with it being aligned.
drivers/media/usb/as102/as10x_cmd.h:379:30: warning: field reg_addr within 'struct as10x_dump_memory::(unnamed at drivers/media/usb/as102/as10x_cmd.h:373:2)' is less aligned than 'struct as10x_register_addr' and is usually due to 'struct as10x_dump_memory::(unnamed at drivers/media/usb/as102/as10x_cmd.h:373:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access]
Mark it as being packed.
--- drivers/media/dvb-frontends/as102_fe_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/as102_fe_types.h +1 -1
@@ -174,6 +174,6 @@ struct as10x_register_addr {uint32_t addr;/* register mode access */ uint8_t mode; -}; +} __packed;#endif
Signature · 1 line
2.44.0.478.gd926399ef9-goog
Re: [PATCH 1/3] media: dvb: as102-fe: Fix as10x_register_addr packing
Quoted 17 lines · Ricardo Ribalda
This structure is embedded in multiple other structures that are packed, which conflicts with it being aligned.
drivers/media/usb/as102/as10x_cmd.h:379:30: warning: fieldreg_addrwithin 'struct as10x_dump_memory::(unnamed atdrivers/media/usb/as102/as10x_cmd.h:373:2)' is less aligned than 'structas10x_register_addr' and is usually due to 'struct as10x_dump_memory::(unnamed atdrivers/media/usb/as102/as10x_cmd.h:373:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access]Mark it as being packed.
Signed-off-by Ricardo Ribalda <[email protected]>--- drivers/media/dvb-frontends/as102_fe_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/dvb-frontends/as102_fe_types.h +0
-0
drivers/media/dvb-frontends/as102_fe_types.h struct as10x_register_addr { · line 177
Quoted 5 lines
drivers/media/dvb-frontends/as102_fe_types.h +1
-1@@ -174,6 +174,6 @@ struct as10x_register_addr {uint32_t addr;/* register mode access */ uint8_t mode; -}; +} __packed;
Changing the layout of a struct is scary, but in this case I believe as10x_register_addr isn't actually used in this driver at all.
So this looks OK.
Regards,
Hans
Quoted 3 lines
drivers/media/dvb-frontends/as102_fe_types.h +0
-0#endif
PATCH 2/3 media: dvb: Fix dtvs_stats packing.
In reply to Ricardo RibaldaThe structure is packed, which requires that all its fields need to be also packed.
./include/uapi/linux/dvb/frontend.h:854:2: warning: field within 'struct dtv_stats' is less aligned than 'union dtv_stats::(anonymous at ./include/uapi/linux/dvb/frontend.h:854:2)' and is usually due to 'struct dtv_stats' being packed, which can lead to unaligned accesses [-Wunaligned-access]
Explicitly set the inner union as packed.
--- include/uapi/linux/dvb/frontend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/dvb/frontend.h +1 -1
@@ -854,7 +854,7 @@ struct dtv_stats {union {__u64 uvalue;/* for counters and relative scales */ __s64 svalue;/* for 0.001 dB measures */ - }; + } __attribute__ ((packed)); } __attribute__ ((packed));
Signature · 1 line
2.44.0.478.gd926399ef9-goog
Re: [PATCH 2/3] media: dvb: Fix dtvs_stats packing.
Quoted 17 lines · Ricardo Ribalda
The structure is packed, which requires that all its fields need to be also packed.
./include/uapi/linux/dvb/frontend.h:854:2: warning: field within 'structdtv_stats' is less aligned than 'union dtv_stats::(anonymous at./include/uapi/linux/dvb/frontend.h:854:2)' and is usually due to 'structdtv_stats' being packed, which can lead to unaligned accesses [-Wunaligned-access]Explicitly set the inner union as packed.
Signed-off-by Ricardo Ribalda <[email protected]>--- include/uapi/linux/dvb/frontend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/uapi/linux/dvb/frontend.h +0
-0
include/uapi/linux/dvb/frontend.h struct dtv_stats { · line 858
Quoted 6 lines
include/uapi/linux/dvb/frontend.h +1
-1@@ -854,7 +854,7 @@ struct dtv_stats {union {__u64 uvalue;/* for counters and relative scales */ __s64 svalue;/* for 0.001 dB measures */ - }; + } __attribute__ ((packed)); } __attribute__ ((packed));
This is used in the public API, and I think this change can cause ABI changes.
Can you compare the layouts? Also between gcc and llvm since gcc never warned about this.
I'm not going to accept this unless it is clear that there are no ABI changes.
Note that the ABI test in the build scripts only tests V4L2 at the moment, not the DVB API.
Regards,
Hans
Re: [PATCH 2/3] media: dvb: Fix dtvs_stats packing.
Hi Hans
Quoted 28 lines · Hans Verkuil
Quoted 17 lines · Ricardo Ribalda
The structure is packed, which requires that all its fields need to be also packed.
./include/uapi/linux/dvb/frontend.h:854:2: warning: field within 'structdtv_stats' is less aligned than 'union dtv_stats::(anonymous at./include/uapi/linux/dvb/frontend.h:854:2)' and is usually due to 'structdtv_stats' being packed, which can lead to unaligned accesses [-Wunaligned-access]Explicitly set the inner union as packed.
Signed-off-by Ricardo Ribalda <[email protected]>--- include/uapi/linux/dvb/frontend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/uapi/linux/dvb/frontend.h +0
-0include/uapi/linux/dvb/frontend.h struct dtv_stats { · line 858
Quoted 6 lines
include/uapi/linux/dvb/frontend.h +1
-1@@ -854,7 +854,7 @@ struct dtv_stats {union {__u64 uvalue;/* for counters and relative scales */ __s64 svalue;/* for 0.001 dB measures */ - }; + } __attribute__ ((packed)); } __attribute__ ((packed));This is used in the public API, and I think this change can cause ABI changes.
Quoted 2 lines
Can you compare the layouts? Also between gcc and llvm since gcc never warned about this.
The pahole output looks the same in both cases:
https://godbolt.org/z/oK4desv7Y
vs
https://godbolt.org/z/E36MjPr7v
And it is also the same for all the compiler versions that I tried.
struct dtv_stats {uint8_t scale; /* 0 1 */
union {
uint64_t uvalue; /* 1 8 */ int64_t svalue; /* 1 8 */
}; /* 1 8 */
/* size: 9, cachelines: 1, members: 2 */
/* last cacheline: 9 bytes */
} __attribute__((__packed__));
struct dtv_stats {uint8_t scale; /* 0 1 */
union {uint64_t uvalue; /* 1 8 */int64_t svalue; /* 1 8 */
}; /* 1 8 */
/* size: 9, cachelines: 1, members: 2 */
/* last cacheline: 9 bytes */
} __attribute__((__packed__));
Quoted 2 lines
I'm not going to accept this unless it is clear that there are no ABI changes.
Is there something else that I can try?
Regards!
Quoted 8 lines
Note that the ABI test in the build scripts only tests V4L2 at the moment, not the DVB API.
Regards,
Hans
Signature · 1 line
Ricardo Ribalda
Re: [PATCH 2/3] media: dvb: Fix dtvs_stats packing.
Hi Ricardo,
Quoted 69 lines · Ricardo Ribalda
Hi Hans
Quoted 28 lines · Hans Verkuil
Quoted 17 lines · Ricardo Ribalda
The structure is packed, which requires that all its fields need to be also packed.
./include/uapi/linux/dvb/frontend.h:854:2: warning: field within 'structdtv_stats' is less aligned than 'union dtv_stats::(anonymous at./include/uapi/linux/dvb/frontend.h:854:2)' and is usually due to 'structdtv_stats' being packed, which can lead to unaligned accesses [-Wunaligned-access]Explicitly set the inner union as packed.
Signed-off-by Ricardo Ribalda <[email protected]>--- include/uapi/linux/dvb/frontend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/uapi/linux/dvb/frontend.h +0
-0include/uapi/linux/dvb/frontend.h struct dtv_stats { · line 858
Quoted 6 lines
include/uapi/linux/dvb/frontend.h +1
-1@@ -854,7 +854,7 @@ struct dtv_stats {union {__u64 uvalue;/* for counters and relative scales */ __s64 svalue;/* for 0.001 dB measures */ - }; + } __attribute__ ((packed)); } __attribute__ ((packed));This is used in the public API, and I think this change can cause ABI changes.
Quoted 2 lines
Can you compare the layouts? Also between gcc and llvm since gcc never warned about this.
The pahole output looks the same in both cases:
https://godbolt.org/z/oK4desv7Y
vs
https://godbolt.org/z/E36MjPr7vAnd it is also the same for all the compiler versions that I tried.
struct
dtv_stats{uint8_tscale; /* 0 1 */
union {uint64_t uvalue; /* 1 8 */ int64_t svalue; /* 1 8 */}; /* 1 8 */
/* size: 9, cachelines: 1, members: 2 */
/* last cacheline: 9 bytes */
} __attribute__((__packed__));struct
dtv_stats{uint8_tscale; /* 0 1 */
union {uint64_tuvalue; /* 1 8 */int64_tsvalue; /* 1 8 */
}; /* 1 8 *//* size: 9, cachelines: 1, members: 2 */
/* last cacheline: 9 bytes */
} __attribute__((__packed__));Quoted 1 line
Quoted 3 lines
Quoted 1 line
I'm not going to accept this unless it is clear that there are no ABI changes.
Is there something else that I can try?
No, that's what I needed. I also found some clang discussions here:
https://github.com/llvm/llvm-project/issues/55520
I propose that I add the following sentence to these three packing patches:
"Marking the inner union as 'packed' does not change the layout, since the whole struct is already packed, it just silences the clang warning. See also this llvm discussion: https://github.com/llvm/llvm-project/issues/55520"
If you are OK with that, then I can add that to your patches.
Related to this: I added CEC and DVB support to the ABI checks in the build scripts. And fixed a bunch of mistakes there (e.g. 'false=true' where I meant to write 'fail=true'!) that made the ABI checks useless.
I updated the abi/* files accordingly as well.
Regards,
Hans
Quoted 13 lines
Regards!
Quoted 8 lines
Note that the ABI test in the build scripts only tests V4L2 at the moment, not the DVB API.
Regards,
Hans
Re: [PATCH 2/3] media: dvb: Fix dtvs_stats packing.
Hi Hans
Quoted 81 lines · Hans Verkuil
Hi Ricardo,
Quoted 69 lines · Ricardo Ribalda
Hi Hans
Quoted 28 lines · Hans Verkuil
Quoted 17 lines · Ricardo Ribalda
The structure is packed, which requires that all its fields need to be also packed.
./include/uapi/linux/dvb/frontend.h:854:2: warning: field within 'structdtv_stats' is less aligned than 'union dtv_stats::(anonymous at./include/uapi/linux/dvb/frontend.h:854:2)' and is usually due to 'structdtv_stats' being packed, which can lead to unaligned accesses [-Wunaligned-access]Explicitly set the inner union as packed.
Signed-off-by Ricardo Ribalda <[email protected]>--- include/uapi/linux/dvb/frontend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/uapi/linux/dvb/frontend.h +0
-0include/uapi/linux/dvb/frontend.h struct dtv_stats { · line 858
Quoted 6 lines
include/uapi/linux/dvb/frontend.h +1
-1@@ -854,7 +854,7 @@ struct dtv_stats {union {__u64 uvalue;/* for counters and relative scales */ __s64 svalue;/* for 0.001 dB measures */ - }; + } __attribute__ ((packed)); } __attribute__ ((packed));This is used in the public API, and I think this change can cause ABI changes.
Quoted 2 lines
Can you compare the layouts? Also between gcc and llvm since gcc never warned about this.
The pahole output looks the same in both cases:
https://godbolt.org/z/oK4desv7Y
vs
https://godbolt.org/z/E36MjPr7vAnd it is also the same for all the compiler versions that I tried.
struct
dtv_stats{uint8_tscale; /* 0 1 */
union {uint64_t uvalue; /* 1 8 */ int64_t svalue; /* 1 8 */}; /* 1 8 */
/* size: 9, cachelines: 1, members: 2 */
/* last cacheline: 9 bytes */
} __attribute__((__packed__));struct
dtv_stats{uint8_tscale; /* 0 1 */
union {uint64_tuvalue; /* 1 8 */int64_tsvalue; /* 1 8 */
}; /* 1 8 *//* size: 9, cachelines: 1, members: 2 */
/* last cacheline: 9 bytes */
} __attribute__((__packed__));Quoted 1 line
Quoted 3 lines
Quoted 1 line
I'm not going to accept this unless it is clear that there are no ABI changes.
Is there something else that I can try?
No, that's what I needed. I also found some clang discussions here:
Quoted 7 lines
I propose that I add the following sentence to these three packing patches:
"Marking the inner union as 'packed' does not change the layout, since the whole struct is already packed, it just silences the clang warning. See also this llvm discussion: https://github.com/llvm/llvm-project/issues/55520"
If you are OK with that, then I can add that to your patches.
That sounds great. Thanks!
Quoted 4 lines
Related to this: I added CEC and DVB support to the ABI checks in the build scripts. And fixed a bunch of mistakes there (e.g. 'false=true' where I meant to write 'fail=true'!) that made the ABI checks useless.
Ferpect!, I will update it in media-ci
Thanks!
Quoted 21 lines
I updated the abi/* files accordingly as well.
Regards,
Hans
Quoted 13 lines
Regards!
Quoted 8 lines
Note that the ABI test in the build scripts only tests V4L2 at the moment, not the DVB API.
Regards,
Hans
Signature · 1 line
Ricardo Ribalda
PATCH 3/3 media: videodev2: Fix v4l2_ext-control packing.
In reply to Ricardo RibaldaThe structure is packed, which requires that all its fields need to be also packed.
./include/uapi/linux/videodev2.h:1810:2: warning: field within 'struct v4l2_ext_control' is less aligned than 'union v4l2_ext_control::(anonymous at ./include/uapi/linux/videodev2.h:1810:2)' and is usually due to 'struct v4l2_ext_control' being packed, which can lead to unaligned accesses [-Wunaligned-access]
Explicitly set the inner union as packed.
--- include/uapi/linux/videodev2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/videodev2.h +1 -1
@@ -1842,7 +1842,7 @@ struct v4l2_ext_control {struct v4l2_ctrl_hdr10_cll_info __user *p_hdr10_cll_info;struct v4l2_ctrl_hdr10_mastering_display __user *p_hdr10_mastering_display;void __user *ptr; - }; + } __attribute__ ((packed)); } __attribute__ ((packed));struct v4l2_ext_controls {
Signature · 1 line
2.44.0.478.gd926399ef9-goog