diff mbox

[4/6] usb: audio: Fix variable length field to be variable.

Message ID 20171129105532.15420-5-jorge.sanjuan@codethink.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Jorge Sanjuan Nov. 29, 2017, 10:55 a.m. UTC
Make bmaControls be a pointer insted of a fixed size array so it
can have a variable length.

Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
---
 include/linux/usb/audio-v3.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Clemens Ladisch Nov. 29, 2017, 11:33 a.m. UTC | #1
Jorge Sanjuan wrote:
> Make bmaControls be a pointer insted of a fixed size array so it
> can have a variable length.

>  	/* bmaControls is actually u32,
>  	 * but u8 is needed for the hybrid parser */
> -	__u8 bmaControls[0]; /* variable length */
> +	__u8 bmaControls[]; /* variable length */
>  	/* wFeatureDescrStr omitted */
>  } __attribute__((packed));

This is not a pointer but a flexible array member.
And in theory, it does not change anything:
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html


Regards,
Clemens
diff mbox

Patch

diff --git a/include/linux/usb/audio-v3.h b/include/linux/usb/audio-v3.h
index cbbe51e309dd..68f651e8d11a 100644
--- a/include/linux/usb/audio-v3.h
+++ b/include/linux/usb/audio-v3.h
@@ -176,7 +176,7 @@  struct uac3_feature_unit_descriptor {
 	__u8 bSourceID;
 	/* bmaControls is actually u32,
 	 * but u8 is needed for the hybrid parser */
-	__u8 bmaControls[0]; /* variable length */
+	__u8 bmaControls[]; /* variable length */
 	/* wFeatureDescrStr omitted */
 } __attribute__((packed));