Message ID | 20250505060640.3398500-1-hch@lst.de |
---|---|
State | New |
Headers | show |
Series | scsi: remove the stream_status member from scsi_stream_status_header | expand |
On 5/4/25 11:06 PM, Christoph Hellwig wrote: > 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. > > Reported-by: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Signed-off-by: Christoph Hellwig <hch@lst.de> > Reviewed-by: John Garry <john.g.garry@oracle.com> > --- > drivers/scsi/sd.c | 2 +- > include/scsi/scsi_proto.h | 3 +-- > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c > index 950d8c9fb884..3f6e87705b62 100644 > --- a/drivers/scsi/sd.c > +++ b/drivers/scsi/sd.c > @@ -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) > diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h > index aeca37816506..f64385cde5b9 100644 > --- a/include/scsi/scsi_proto.h > +++ b/include/scsi/scsi_proto.h > @@ -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); Reviewed-by: Bart Van Assche <bvanassche@acm.org>
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 950d8c9fb884..3f6e87705b62 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -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) diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h index aeca37816506..f64385cde5b9 100644 --- a/include/scsi/scsi_proto.h +++ b/include/scsi/scsi_proto.h @@ -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);