mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: mpi3mr: Replace one-element arrays with flexible-array members
@ 2025-09-05  1:43 Pedro Demarchi Gomes
  2025-09-05 16:47 ` Christophe JAILLET
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro Demarchi Gomes @ 2025-09-05  1:43 UTC (permalink / raw)
  To: martin.petersen, James.Bottomley
  Cc: linux-scsi, linux-kernel, Pedro Demarchi Gomes

One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in multiple structures.

Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
---
 include/uapi/scsi/scsi_bsg_mpi3mr.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/uapi/scsi/scsi_bsg_mpi3mr.h b/include/uapi/scsi/scsi_bsg_mpi3mr.h
index f5ea1db92339..9e5b6ced53ab 100644
--- a/include/uapi/scsi/scsi_bsg_mpi3mr.h
+++ b/include/uapi/scsi/scsi_bsg_mpi3mr.h
@@ -205,7 +205,7 @@ struct mpi3mr_all_tgt_info {
 	__u16	num_devices;
 	__u16	rsvd1;
 	__u32	rsvd2;
-	struct mpi3mr_device_map_info dmi[1];
+	struct mpi3mr_device_map_info dmi[];
 };
 
 /**
@@ -248,7 +248,7 @@ struct mpi3mr_logdata_entry {
 	__u8	valid_entry;
 	__u8	rsvd1;
 	__u16	rsvd2;
-	__u8	data[1]; /* Variable length Array */
+	__u8	data[]; /* Variable length Array */
 };
 
 /**
@@ -259,7 +259,7 @@ struct mpi3mr_logdata_entry {
  * @entry: Variable length Log data entry array
  */
 struct mpi3mr_bsg_in_log_data {
-	struct mpi3mr_logdata_entry entry[1];
+	__DECLARE_FLEX_ARRAY(struct mpi3mr_logdata_entry, entry);
 };
 
 /**
@@ -307,7 +307,7 @@ struct mpi3mr_bsg_in_hdb_status {
 	__u8    element_trigger_format;
 	__u16	rsvd2;
 	__u32	rsvd3;
-	struct mpi3mr_hdb_entry entry[1];
+	struct mpi3mr_hdb_entry entry[];
 };
 
 /**
@@ -416,7 +416,7 @@ struct mpi3mr_buf_entry_list {
 	__u8	rsvd1;
 	__u16	rsvd2;
 	__u32	rsvd3;
-	struct mpi3mr_buf_entry buf_entry[1];
+	struct mpi3mr_buf_entry buf_entry[];
 };
 /**
  * struct mpi3mr_bsg_mptcmd -  Generic bsg data
-- 
2.39.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: mpi3mr: Replace one-element arrays with flexible-array members
  2025-09-05  1:43 [PATCH] scsi: mpi3mr: Replace one-element arrays with flexible-array members Pedro Demarchi Gomes
@ 2025-09-05 16:47 ` Christophe JAILLET
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe JAILLET @ 2025-09-05 16:47 UTC (permalink / raw)
  To: Pedro Demarchi Gomes, martin.petersen, James.Bottomley
  Cc: linux-scsi, linux-kernel

Le 05/09/2025 à 03:43, Pedro Demarchi Gomes a écrit :
> One-element arrays are deprecated, and we are replacing them with flexible
> array members instead. So, replace one-element arrays with flexible-array
> members in multiple structures.
> 
> Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
> ---
>   include/uapi/scsi/scsi_bsg_mpi3mr.h | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/include/uapi/scsi/scsi_bsg_mpi3mr.h b/include/uapi/scsi/scsi_bsg_mpi3mr.h
> index f5ea1db92339..9e5b6ced53ab 100644
> --- a/include/uapi/scsi/scsi_bsg_mpi3mr.h
> +++ b/include/uapi/scsi/scsi_bsg_mpi3mr.h
> @@ -205,7 +205,7 @@ struct mpi3mr_all_tgt_info {
>   	__u16	num_devices;
>   	__u16	rsvd1;
>   	__u32	rsvd2;
> -	struct mpi3mr_device_map_info dmi[1];
> +	struct mpi3mr_device_map_info dmi[];
>   };
>   
>   /**
> @@ -248,7 +248,7 @@ struct mpi3mr_logdata_entry {
>   	__u8	valid_entry;
>   	__u8	rsvd1;
>   	__u16	rsvd2;
> -	__u8	data[1]; /* Variable length Array */
> +	__u8	data[]; /* Variable length Array */
>   };
>   
>   /**
> @@ -259,7 +259,7 @@ struct mpi3mr_logdata_entry {
>    * @entry: Variable length Log data entry array
>    */
>   struct mpi3mr_bsg_in_log_data {
> -	struct mpi3mr_logdata_entry entry[1];
> +	__DECLARE_FLEX_ARRAY(struct mpi3mr_logdata_entry, entry);
>   };
>   
>   /**
> @@ -307,7 +307,7 @@ struct mpi3mr_bsg_in_hdb_status {
>   	__u8    element_trigger_format;
>   	__u16	rsvd2;
>   	__u32	rsvd3;
> -	struct mpi3mr_hdb_entry entry[1];
> +	struct mpi3mr_hdb_entry entry[];

I think that the -1 at [1] should be removed, and struct_size() used 
instead.

The same kind of issue is maybe also relevant for the other changes, but 
I've not spotted such places myself.

CJ

[1]: 
https://elixir.bootlin.com/linux/v6.17-rc4/source/drivers/scsi/mpi3mr/mpi3mr_app.c#L1245

>   };
>   
>   /**
> @@ -416,7 +416,7 @@ struct mpi3mr_buf_entry_list {
>   	__u8	rsvd1;
>   	__u16	rsvd2;
>   	__u32	rsvd3;
> -	struct mpi3mr_buf_entry buf_entry[1];
> +	struct mpi3mr_buf_entry buf_entry[];
>   };
>   /**
>    * struct mpi3mr_bsg_mptcmd -  Generic bsg data


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-05 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-05  1:43 [PATCH] scsi: mpi3mr: Replace one-element arrays with flexible-array members Pedro Demarchi Gomes
2025-09-05 16:47 ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®