Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace one-element arrays in sound/pci/mixart/mixart_core.h #296

Closed
GustavoARSilva opened this issue May 17, 2023 · 1 comment
Closed
Assignees
Labels
[Linux] v6.5 Released in Linux kernel v6.5 [Refactor] 1-element array Conversion away from one-element array

Comments

@GustavoARSilva
Copy link
Collaborator

diff -u -p a/sound/pci/mixart/mixart_core.h b/sound/pci/mixart/mixart_core.h
--- a/sound/pci/mixart/mixart_core.h
+++ b/sound/pci/mixart/mixart_core.h
@@ -231,7 +231,7 @@ struct mixart_group_state_req
        u64           scheduler;
        u32           reserved4np[2];
        u32           pipe_count;    /* set to 1 for instance */
-       struct mixart_uid  pipe_uid[1];   /* could be an array[pipe_count] */
+       struct mixart_uid pipe_uid[];   /* could be an array[pipe_count] */
 } __attribute__((packed));

 struct mixart_group_state_resp
@@ -314,7 +314,7 @@ struct mixart_clock_properties
        u32 format;
        u32 board_mask;
        u32 nb_callers; /* set to 1 (see below) */
-       struct mixart_uid uid_caller[1];
+       struct mixart_uid uid_caller[];
 } __attribute__((packed));

 struct mixart_clock_properties_resp
@@ -401,7 +401,7 @@ struct mixart_stream_param_desc
        u32 reserved4np[3];
        u32 pipe_count;                           /* set to 1 (array size !) */
        u32 stream_count;                         /* set to 1 (array size !) */
-       struct mixart_txx_stream_desc stream_desc[1];  /* only one stream per command, but this could be an array */
+       struct mixart_txx_stream_desc stream_desc[];  /* only one stream per command, but this could be an array */

 } __attribute__((packed));
@GustavoARSilva GustavoARSilva added the [Refactor] 1-element array Conversion away from one-element array label May 17, 2023
@GustavoARSilva GustavoARSilva self-assigned this May 17, 2023
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue May 17, 2023
One-element arrays are deprecated, and we are replacing them with flexible
array members, instead. However, in this case it seems those one-element
arrays have never actually been used as fake flexible arrays.

See this code that dates from Linux-2.6.12-rc2 initial git repository build
(commit 1da177e ("Linux-2.6.12-rc2")):

sound/pci/mixart/mixart_core.h:
 215 struct mixart_stream_state_req
 216 {
 217         u32                 delayed;
 218         u64                 scheduler;
 219         u32                 reserved4np[3];
 220         u32                 stream_count;  /* set to 1 for instance */
 221         struct mixart_flow_info  stream_info;   /* could be an array[stream_cou    nt] */
 222 } __attribute__((packed));

sound/pci/mixart/mixart.c:
 388
 389         memset(&stream_state_req, 0, sizeof(stream_state_req));
 390         stream_state_req.stream_count = 1;
 391         stream_state_req.stream_info.stream_desc.uid_pipe = stream->pipe->group_uid;
 392         stream_state_req.stream_info.stream_desc.stream_idx = stream->substream->number;
 393

So, taking the code above as example, replace multiple one-element
arrays with simple object declarations, and refactor the rest of the
code, accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].

This results in no differences in binary output.

Link: KSPP#79
Link: KSPP#296
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue May 19, 2023
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. However, in this case it seems those one-element
arrays have never actually been used as fake flexible arrays.

See this code that dates from Linux-2.6.12-rc2 initial git repository build
(commit 1da177e ("Linux-2.6.12-rc2")):

sound/pci/mixart/mixart_core.h:
 215 struct mixart_stream_state_req
 216 {
 217         u32                 delayed;
 218         u64                 scheduler;
 219         u32                 reserved4np[3];
 220         u32                 stream_count;  /* set to 1 for instance */
 221         struct mixart_flow_info  stream_info;   /* could be an array[stream_count] */
 222 } __attribute__((packed));

sound/pci/mixart/mixart.c:
 388
 389         memset(&stream_state_req, 0, sizeof(stream_state_req));
 390         stream_state_req.stream_count = 1;
 391         stream_state_req.stream_info.stream_desc.uid_pipe = stream->pipe->group_uid;
 392         stream_state_req.stream_info.stream_desc.stream_idx = stream->substream->number;
 393

So, taking the code above as example, replace multiple one-element
arrays with simple object declarations, and refactor the rest of the
code, accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].

This results in no differences in binary output.

Link: KSPP#79
Link: KSPP#296
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
tiwai pushed a commit to tiwai/sound that referenced this issue May 20, 2023
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. However, in this case it seems those one-element
arrays have never actually been used as fake flexible arrays.

See this code that dates from Linux-2.6.12-rc2 initial git repository build
(commit 1da177e ("Linux-2.6.12-rc2")):

sound/pci/mixart/mixart_core.h:
 215 struct mixart_stream_state_req
 216 {
 217         u32                 delayed;
 218         u64                 scheduler;
 219         u32                 reserved4np[3];
 220         u32                 stream_count;  /* set to 1 for instance */
 221         struct mixart_flow_info  stream_info;   /* could be an array[stream_count] */
 222 } __attribute__((packed));

sound/pci/mixart/mixart.c:
 388
 389         memset(&stream_state_req, 0, sizeof(stream_state_req));
 390         stream_state_req.stream_count = 1;
 391         stream_state_req.stream_info.stream_desc.uid_pipe = stream->pipe->group_uid;
 392         stream_state_req.stream_info.stream_desc.stream_idx = stream->substream->number;
 393

So, taking the code above as example, replace multiple one-element
arrays with simple object declarations, and refactor the rest of the
code, accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].

This results in no differences in binary output.

Link: KSPP#79
Link: KSPP#296
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZGfiFjcL8+r3mayq@work
Signed-off-by: Takashi Iwai <tiwai@suse.de>
@kees kees added the [Linux] v6.5 Released in Linux kernel v6.5 label Feb 6, 2024
@kees
Copy link

kees commented Feb 6, 2024

Fixed in commit 4040fc5.

@kees kees closed this as completed Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Linux] v6.5 Released in Linux kernel v6.5 [Refactor] 1-element array Conversion away from one-element array
Projects
None yet
Development

No branches or pull requests

2 participants