scsi: remove the stream_status member from scsi_stream_status_header
PATCH 1/1 scsi: remove the stream_status member from scsi_stream_status_header
Having a variable length array at the end of scsi_stream_status_header only cause problems. Remove it and switch sd_is_perm_stream which is the only place that currently uses it to use the scsi_stream_status directly following it in the local buf structure.
Besides being a much better data structure design, this also avoids a -Wflex-array-member-not-at-end warning.
--- drivers/scsi/sd.c | 2 +- include/scsi/scsi_proto.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/sd.c +1 -1
@@ -3215,7 +3215,7 @@ static bool sd_is_perm_stream(struct scsi_disk *sdkp, unsigned int stream_id)return false;if (get_unaligned_be32 (&buf.h.len) <sizeof (struct scsi_stream_status ))return false; -return buf.h.stream_status[0 ].perm; +return buf.s.perm; }static void sd_read_io_hints (struct scsi_disk *sdkp,unsigned char *buffer)
include/scsi/scsi_proto.h +1 -2
@@ -346,10 +346,9 @@ static_assert(sizeof(struct scsi_stream_status) == 8);/* GET STREAM STATUS parameter data */ struct scsi_stream_status_header { -__be32 len;/* length in bytes of stream_status[] array. */ +__be32 len;/* length in bytes of following payload */ u16 reserved;__be16 number_of_open_streams; - DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status); };static_assert (sizeof (struct scsi_stream_status_header ) ==8 );
Signature · 1 line
2.47.2
Quoted 35 lines · Christoph Hellwig
Having a variable length array at the end of
scsi_stream_status_headeronly cause problems. Remove it and switchsd_is_perm_streamwhich is the only place that currently uses it to use thescsi_stream_statusdirectly following it in the local buf structure.Besides being a much better data structure design, this also avoids a -Wflex-array-member-not-at-end warning.
Reported-by "Gustavo A. R. Silva" <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by John Garry <[email protected]>--- drivers/scsi/sd.c | 2 +- include/scsi/scsi_proto.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)drivers/scsi/sd.c +1
-1@@ -3215,7 +3215,7 @@ static bool sd_is_perm_stream(struct scsi_disk *sdkp, unsigned int stream_id)return false;if (get_unaligned_be32 (&buf.h.len) <sizeof (struct scsi_stream_status ))return false; -return buf.h.stream_status[0 ].perm; +return buf.s.perm; }static void sd_read_io_hints (struct scsi_disk *sdkp,unsigned char *buffer)include/scsi/scsi_proto.h +0
-0@@ -346,10 +346,9 @@ static_assert(sizeof(struct scsi_stream_status) == 8);
include/scsi/scsi_proto.h static_assert(sizeof(struct scsi_stream_status) == 8); · line 354
Quoted 10 lines
include/scsi/scsi_proto.h +1
-2/* GET STREAM STATUS parameter data */ struct scsi_stream_status_header { -__be32 len;/* length in bytes of stream_status[] array. */ +__be32 len;/* length in bytes of following payload */ u16 reserved;__be16 number_of_open_streams; - DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status); };static_assert (sizeof (struct scsi_stream_status_header ) ==8 );
Martin K. Petersen
AppliedChristoph,
Quoted 4 lines
Having a variable length array at the end of
scsi_stream_status_headeronly cause problems. Remove it and switchsd_is_perm_streamwhich is the only place that currently uses it to use thescsi_stream_statusdirectly following it in the local buf structure.
Applied to 6.16/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Martin K. Petersen
AppliedQuoted 9 lines · Christoph Hellwig
Having a variable length array at the end of
scsi_stream_status_headeronly cause problems. Remove it and switchsd_is_perm_streamwhich is the only place that currently uses it to use thescsi_stream_statusdirectly following it in the local buf structure.Besides being a much better data structure design, this also avoids a -Wflex-array-member-not-at-end warning.
[...]
Applied to 6.16/scsi-queue, thanks!
[1/1] scsi: remove the stream_status member from scsi_stream_status_header
https://git.kernel.org/mkp/scsi/c/cd6856d38881
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering