Skip to contentSkip to conversation

ASoC: uapi: Replace zero-length arrays with __DECLARE_FLEX_ARRAY() helper

PATCH In review Gustavo A. R. Silva 5 participants 12 messages Sep 26, 2022 – Feb 3, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: uapi: Replace zero-length arrays with __DECLARE_FLEX_ARRAY() helper

Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations in anonymous union with the new __DECLARE_FLEX_ARRAY() helper macro.

This helper allows for flexible-array members in unions.

---
 include/uapi/sound/asoc.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/uapi/sound/asoc.h +3 -3
index 053949287ce8..dd8ad790fc15 100644
@@ -226,9 +226,9 @@ struct snd_soc_tplg_vendor_array {
 	__le32 type;	/* SND_SOC_TPLG_TUPLE_TYPE_ */
 	__le32 num_elems;	/* number of elements in array */
 	union {
-		struct snd_soc_tplg_vendor_uuid_elem uuid[0];
-		struct snd_soc_tplg_vendor_value_elem value[0];
-		struct snd_soc_tplg_vendor_string_elem string[0];
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_uuid_elem, uuid);
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_value_elem, value);
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_string_elem, string);
 	};
 } __attribute__((packed));
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Gustavo A. R. Silva

Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations in anonymous union with the new __DECLARE_FLEX_ARRAY() helper macro.

This helper allows for flexible-array members in unions.

Some day after the __element_count__ attribute exists, we might want to consider a __type_select__ attribute to tie union members to a variable outside the union (like the "type" member here).

Signature · 1 line
Kees Cook
Reviewed-by on v1 1/1
#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 22 lines · Gustavo A. R. Silva

Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations in anonymous union with the new __DECLARE_FLEX_ARRAY() helper macro.

This helper allows for flexible-array members in unions.

---
  include/uapi/sound/asoc.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
include/uapi/sound/asoc.h +0 -0
index 053949287ce8..dd8ad790fc15 100644
@@ -226,9 +226,9 @@ struct snd_soc_tplg_vendor_array {
  	__le32 type;	/* SND_SOC_TPLG_TUPLE_TYPE_ */
  	__le32 num_elems;	/* number of elements in array */

include/uapi/sound/asoc.h struct snd_soc_tplg_vendor_array { · line 234

Quoted 10 lines
include/uapi/sound/asoc.h +3 -3
  	union {
-		struct snd_soc_tplg_vendor_uuid_elem uuid[0];
-		struct snd_soc_tplg_vendor_value_elem value[0];
-		struct snd_soc_tplg_vendor_string_elem string[0];
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_uuid_elem, uuid);
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_value_elem, value);
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_string_elem, string);
  	};
  } __attribute__((packed));
 
#3 lore raw
In reply to Gustavo A. R. Silva

Hi Takashi,

I wonder if this can go through your tree.

It's already been reviewed by a couple of people. :)

Thanks
--
Gustavo

Quoted 32 lines · Gustavo A. R. Silva

Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations in anonymous union with the new __DECLARE_FLEX_ARRAY() helper macro.

This helper allows for flexible-array members in unions.

---
  include/uapi/sound/asoc.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
include/uapi/sound/asoc.h +3 -3
index 053949287ce8..dd8ad790fc15 100644
@@ -226,9 +226,9 @@ struct snd_soc_tplg_vendor_array {
  	__le32 type;	/* SND_SOC_TPLG_TUPLE_TYPE_ */
  	__le32 num_elems;	/* number of elements in array */
  	union {
-		struct snd_soc_tplg_vendor_uuid_elem uuid[0];
-		struct snd_soc_tplg_vendor_value_elem value[0];
-		struct snd_soc_tplg_vendor_string_elem string[0];
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_uuid_elem, uuid);
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_value_elem, value);
+		__DECLARE_FLEX_ARRAY(struct snd_soc_tplg_vendor_string_elem, string);
  	};
  } __attribute__((packed));
 
maintainer
#4 lore raw
Quoted 5 lines · Gustavo A. R. Silva

Hi Takashi,

I wonder if this can go through your tree.

It's already been reviewed by a couple of people. :)

As documented in submitting-patches.rst please send patches to the maintainers for the code you would like to change. The normal kernel workflow is that people apply patches from their inboxes, if they aren't copied they are likely to not see the patch at all and it is much more difficult to apply patches.

#5 lore raw
Quoted 5 lines · Mark Brown
Quoted 4 lines · Gustavo A. R. Silva

Hi Takashi,

I wonder if this can go through your tree.

Quoted 7 lines
Quoted 1 line

It's already been reviewed by a couple of people. :)

As documented in submitting-patches.rst please send patches to the maintainers for the code you would like to change. The normal kernel workflow is that people apply patches from their inboxes, if they aren't copied they are likely to not see the patch at all and it is much more difficult to apply patches.

Yep; that's exactly what I did. :)

scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/uapi/sound/asoc.h Jaroslav Kysela <[email protected]> (maintainer:SOUND)
Takashi Iwai <[email protected]> (maintainer:SOUND) [email protected] (moderated list:SOUND) [email protected] (open list)

If you're one the maintainers of that file, you're clearly not listed as such.

--
Gustavo

maintainer
#6 lore raw
Quoted 11 lines · Gustavo A. R. Silva
Quoted 7 lines · Mark Brown

On Thu, Feb 02, 2023 at 02:34:17PM -0600, Gustavo A. R. Silva wrote:

As documented in submitting-patches.rst please send patches to the maintainers for the code you would like to change. The normal kernel workflow is that people apply patches from their inboxes, if they aren't copied they are likely to not see the patch at all and it is much more difficult to apply patches.

Yep; that's exactly what I did. :)

Quoted 7 lines

scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/uapi/sound/asoc.h Jaroslav Kysela <[email protected]> (maintainer:SOUND)
Takashi Iwai <[email protected]> (maintainer:SOUND) [email protected] (moderated list:SOUND) [email protected] (open list)

If you're one the maintainers of that file, you're clearly not listed as such.

You did manage to figure out that it's an ASoC patch given the subject line...

#7 lore raw
Quoted 18 lines · Mark Brown
Quoted 16 lines · Gustavo A. R. Silva
Quoted 7 lines · Mark Brown

On Thu, Feb 02, 2023 at 02:34:17PM -0600, Gustavo A. R. Silva wrote:

As documented in submitting-patches.rst please send patches to the maintainers for the code you would like to change. The normal kernel workflow is that people apply patches from their inboxes, if they aren't copied they are likely to not see the patch at all and it is much more difficult to apply patches.

Yep; that's exactly what I did. :)

scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/uapi/sound/asoc.h Jaroslav Kysela <[email protected]> (maintainer:SOUND)
Takashi Iwai <[email protected]> (maintainer:SOUND) [email protected] (moderated list:SOUND) [email protected] (open list)

Quoted 4 lines
Quoted 1 line

If you're one the maintainers of that file, you're clearly not listed as such.

You did manage to figure out that it's an ASoC patch given the subject line...

As with the list of maintainers, I use a tool to get that info:

git log --oneline include/uapi/sound/asoc.h

I think we have run into this same issue (you not being listed in the MAINTAINERS file) at least once in the past, right? (thinkingface)

IMHO, the sensible solution for this is to keep the MAINTAINERS file up-to-date. So, get_maintainer.pl can continue to be useful for people.

--
Gustavo

maintainer
#8 lore raw
Quoted 5 lines · Gustavo A. R. Silva

I think we have run into this same issue (you not being listed in the MAINTAINERS file) at least once in the past, right? (thinkingface)

IMHO, the sensible solution for this is to keep the MAINTAINERS file up-to-date. So, get_maintainer.pl can continue to be useful for people.

Sure, feel free to send an update...

#9 lore raw
Quoted 9 lines · Mark Brown
Quoted 5 lines · Gustavo A. R. Silva

I think we have run into this same issue (you not being listed in the MAINTAINERS file) at least once in the past, right? (thinkingface)

IMHO, the sensible solution for this is to keep the MAINTAINERS file up-to-date. So, get_maintainer.pl can continue to be useful for people.

Sure, feel free to send an update...

[chuckles]

#10 lore raw
In reply to Mark Brown
Quoted 9 lines · Mark Brown
Quoted 5 lines · Gustavo A. R. Silva

I think we have run into this same issue (you not being listed in the MAINTAINERS file) at least once in the past, right? (thinkingface)

IMHO, the sensible solution for this is to keep the MAINTAINERS file up-to-date. So, get_maintainer.pl can continue to be useful for people.

Sure, feel free to send an update...

Is this accurate?

MAINTAINERS +2 -0
index 7f86d02cb427..e21a3412a546 100644
@@ -19564,6 +19564,8 @@ F:	Documentation/devicetree/bindings/sound/
 F:	Documentation/sound/soc/
 F:	include/dt-bindings/sound/
 F:	include/sound/soc*
+F:	include/sound/sof/
+F:	include/uapi/sound/asoc.h
 F:	sound/soc/
 
 SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS
Signature · 1 line
Kees Cook
maintainer
#11 lore raw
Quoted 11 lines · Kees Cook
Quoted 1 line · Mark Brown

Sure, feel free to send an update...

Is this accurate?

MAINTAINERS +0 -0
index 7f86d02cb427..e21a3412a546 100644

MAINTAINERS F: Documentation/devicetree/bindings/sound/ · line 19569

Quoted 6 lines
MAINTAINERS +2 -0
@@ -19564,6 +19564,8 @@ F:	Documentation/devicetree/bindings/sound/
 F:	Documentation/sound/soc/
 F:	include/dt-bindings/sound/
 F:	include/sound/soc*
+F:	include/sound/sof/
+F:	include/uapi/sound/asoc.h
 F:	sound/soc/

Might be missing stuff but those are both good additions. Looks like the SOF directory also wants adding to the SOF section in MAINTAINERS.