From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@infradead.org>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org
Subject: [PATCH v2][next] scsi: sd: Avoid -Wflex-array-member-not-at-end warning
Date: Thu, 1 May 2025 12:39:27 -0600 [thread overview]
Message-ID: <aBO_32OsMj3hsJsv@kspp> (raw)
Apparently, the flexible-array member in `struct scsi_stream_status_header`
is not actually needed. Remove it along with the related KUnit test.
So, with these changes, fix the following warning:
drivers/scsi/sd.c:3195:50: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Co-developed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
Changes in v2:
- Revome flexible-array member. (Christoph)
v1:
- Link: https://lore.kernel.org/linux-hardening/aAwos0mLxneG9R_t@kspp/
drivers/scsi/scsi_proto_test.c | 8 --------
drivers/scsi/sd.c | 2 +-
include/scsi/scsi_proto.h | 1 -
3 files changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/scsi/scsi_proto_test.c b/drivers/scsi/scsi_proto_test.c
index c093389edabb..2fc5c6523184 100644
--- a/drivers/scsi/scsi_proto_test.c
+++ b/drivers/scsi/scsi_proto_test.c
@@ -30,14 +30,6 @@ static void test_scsi_proto(struct kunit *test)
KUNIT_EXPECT_EQ(test, get_unaligned_be16(&ss.s.stream_identifier),
0x1234);
KUNIT_EXPECT_EQ(test, ss.s.rel_lifetime + 0, 0x3f);
-
- static const union {
- struct scsi_stream_status_header h;
- u8 arr[sizeof(struct scsi_stream_status_header)];
- } sh = { .arr = { 1, 2, 3, 4, 0, 0, 5, 6 } };
- KUNIT_EXPECT_EQ(test, get_unaligned_be32(&sh.h.len), 0x1020304);
- KUNIT_EXPECT_EQ(test, get_unaligned_be16(&sh.h.number_of_open_streams),
- 0x506);
}
static struct kunit_case scsi_proto_test_cases[] = {
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..bc8f2b2226be 100644
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -349,7 +349,6 @@ struct scsi_stream_status_header {
__be32 len; /* length in bytes of stream_status[] array. */
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);
--
2.43.0
next reply other threads:[~2025-05-01 18:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-01 18:39 Gustavo A. R. Silva [this message]
2025-05-02 6:50 ` [PATCH v2][next] scsi: sd: Avoid -Wflex-array-member-not-at-end warning Christoph Hellwig
2025-05-03 19:08 ` Bart Van Assche
2025-05-05 6:22 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aBO_32OsMj3hsJsv@kspp \
--to=gustavoars@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=hch@infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox