* [PATCH v2 1/9] usb: storage: jumpshot: Use const for constant arrays
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 2/9] usb: storage: transport: Use const for constant array Jonathan Neuschäfer via B4 Relay
` (8 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
These arrays are not modified. Make them const.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- use consistent authorship information
---
drivers/usb/storage/jumpshot.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index 39ca84d6859122903de4e64b13e697e8b7d4ab31..089c6f8ac85fbb683cca8b03a2ff06c0ca776167 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -367,16 +367,16 @@ static int jumpshot_handle_mode_sense(struct us_data *us,
struct scsi_cmnd * srb,
int sense_6)
{
- static unsigned char rw_err_page[12] = {
+ static const unsigned char rw_err_page[12] = {
0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0
};
- static unsigned char cache_page[12] = {
+ static const unsigned char cache_page[12] = {
0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- static unsigned char rbac_page[12] = {
+ static const unsigned char rbac_page[12] = {
0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0
};
- static unsigned char timer_page[8] = {
+ static const unsigned char timer_page[8] = {
0x1C, 0x6, 0, 0, 0, 0
};
unsigned char pc, page_code;
@@ -477,7 +477,7 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
int rc;
unsigned long block, blocks;
unsigned char *ptr = us->iobuf;
- static unsigned char inquiry_response[8] = {
+ static const unsigned char inquiry_response[8] = {
0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
};
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 2/9] usb: storage: transport: Use const for constant array
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 1/9] usb: storage: jumpshot: Use const for constant arrays Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 3/9] usb: storage: alauda: Use const for card ID array Jonathan Neuschäfer via B4 Relay
` (7 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
This array is only read, not modified
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/transport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index e6bc8ecaecbb202714be69c6db6b0a4824de4855..1aa1bd26c81f2f9fbd508fdfed4465e6482bdef0 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -528,7 +528,7 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
u32 sector;
/* To Report "Medium Error: Record Not Found */
- static unsigned char record_not_found[18] = {
+ static const unsigned char record_not_found[18] = {
[0] = 0x70, /* current error */
[2] = MEDIUM_ERROR, /* = 0x03 */
[7] = 0x0a, /* additional length */
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 3/9] usb: storage: alauda: Use const for card ID array
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 1/9] usb: storage: jumpshot: Use const for constant arrays Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 2/9] usb: storage: transport: Use const for constant array Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 4/9] usb: storage: datafab: Use const for constant arrays Jonathan Neuschäfer via B4 Relay
` (6 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
The alauda_card_ids array is only read, and not modified.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/alauda.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 6263c4e61678e890e0192c5c9dad9b97dbaf0e66..e01f3a42bde4200da245c17abd5299c062868204 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -174,7 +174,7 @@ struct alauda_card_info {
unsigned char zoneshift; /* 1<<zs blocks per zone */
};
-static struct alauda_card_info alauda_card_ids[] = {
+static const struct alauda_card_info alauda_card_ids[] = {
/* NAND flash */
{ 0x6e, 20, 8, 4, 8}, /* 1 MB */
{ 0xe8, 20, 8, 4, 8}, /* 1 MB */
@@ -200,7 +200,7 @@ static struct alauda_card_info alauda_card_ids[] = {
{ 0,}
};
-static struct alauda_card_info *alauda_card_find_id(unsigned char id)
+static const struct alauda_card_info *alauda_card_find_id(unsigned char id)
{
int i;
@@ -383,7 +383,7 @@ static int alauda_init_media(struct us_data *us)
{
unsigned char *data = us->iobuf;
int ready = 0;
- struct alauda_card_info *media_info;
+ const struct alauda_card_info *media_info;
unsigned int num_zones;
while (ready == 0) {
@@ -1132,7 +1132,7 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
int rc;
struct alauda_info *info = (struct alauda_info *) us->extra;
unsigned char *ptr = us->iobuf;
- static unsigned char inquiry_response[36] = {
+ static const unsigned char inquiry_response[36] = {
0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
};
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 4/9] usb: storage: datafab: Use const for constant arrays
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
` (2 preceding siblings ...)
2025-02-26 14:17 ` [PATCH v2 3/9] usb: storage: alauda: Use const for card ID array Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 5/9] usb: storage: initializers: Use const for constant array Jonathan Neuschäfer via B4 Relay
` (5 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
These arrays are only read, not modified.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/datafab.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
index bbfa2398b17036f431c0692bbf794bdb01d68cdf..9ba369483c9b36c2f662749c32bf81b525ae897f 100644
--- a/drivers/usb/storage/datafab.c
+++ b/drivers/usb/storage/datafab.c
@@ -319,7 +319,7 @@ static int datafab_determine_lun(struct us_data *us,
//
// There might be a better way of doing this?
- static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 };
+ static const unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 };
unsigned char *command = us->iobuf;
unsigned char *buf;
int count = 0, rc;
@@ -384,7 +384,7 @@ static int datafab_id_device(struct us_data *us,
// to the ATA spec, 'Sector Count' isn't used but the Windows driver
// sets this bit so we do too...
//
- static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 };
+ static const unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 };
unsigned char *command = us->iobuf;
unsigned char *reply;
int rc;
@@ -437,16 +437,16 @@ static int datafab_handle_mode_sense(struct us_data *us,
struct scsi_cmnd * srb,
int sense_6)
{
- static unsigned char rw_err_page[12] = {
+ static const unsigned char rw_err_page[12] = {
0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0
};
- static unsigned char cache_page[12] = {
+ static const unsigned char cache_page[12] = {
0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- static unsigned char rbac_page[12] = {
+ static const unsigned char rbac_page[12] = {
0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0
};
- static unsigned char timer_page[8] = {
+ static const unsigned char timer_page[8] = {
0x1C, 0x6, 0, 0, 0, 0
};
unsigned char pc, page_code;
@@ -550,7 +550,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
int rc;
unsigned long block, blocks;
unsigned char *ptr = us->iobuf;
- static unsigned char inquiry_reply[8] = {
+ static const unsigned char inquiry_reply[8] = {
0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
};
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 5/9] usb: storage: initializers: Use const for constant array
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
` (3 preceding siblings ...)
2025-02-26 14:17 ` [PATCH v2 4/9] usb: storage: datafab: Use const for constant arrays Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 6/9] usb: storage: realtek_cr: Use const for constant arrays Jonathan Neuschäfer via B4 Relay
` (4 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
init_string is only read, not modified.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/initializers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
index f8f9ce8dc71029aff5ceaf4d62f596a30bbceca2..b243bd5521a66deb3ca3603b52ccf603e191a4de 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -54,7 +54,7 @@ int usb_stor_ucr61s2b_init(struct us_data *us)
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap*) us->iobuf;
int res;
unsigned int partial;
- static char init_string[] = "\xec\x0a\x06\x00$PCCHIPS";
+ static const char init_string[] = "\xec\x0a\x06\x00$PCCHIPS";
usb_stor_dbg(us, "Sending UCR-61S2B initialization packet...\n");
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 6/9] usb: storage: realtek_cr: Use const for constant arrays
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
` (4 preceding siblings ...)
2025-02-26 14:17 ` [PATCH v2 5/9] usb: storage: initializers: Use const for constant array Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 7/9] usb: storage: sddr09: " Jonathan Neuschäfer via B4 Relay
` (3 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
These arrays are only read, never modified.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/realtek_cr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 2a82ed7b68eaa75993e786afeda0d5d3a3c3bfce..4e516b44513672ebe7889247a70043e0dd013bc8 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -191,7 +191,7 @@ MODULE_DEVICE_TABLE(usb, realtek_cr_ids);
.initFunction = init_function, \
}
-static struct us_unusual_dev realtek_cr_unusual_dev_list[] = {
+static const struct us_unusual_dev realtek_cr_unusual_dev_list[] = {
# include "unusual_realtek.h"
{} /* Terminating entry */
};
@@ -797,10 +797,10 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
{
struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
static int card_first_show = 1;
- static u8 media_not_present[] = { 0x70, 0, 0x02, 0, 0, 0, 0,
+ static const u8 media_not_present[] = { 0x70, 0, 0x02, 0, 0, 0, 0,
10, 0, 0, 0, 0, 0x3A, 0, 0, 0, 0, 0
};
- static u8 invalid_cmd_field[] = { 0x70, 0, 0x05, 0, 0, 0, 0,
+ static const u8 invalid_cmd_field[] = { 0x70, 0, 0x05, 0, 0, 0, 0,
10, 0, 0, 0, 0, 0x24, 0, 0, 0, 0, 0
};
int ret;
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 7/9] usb: storage: sddr09: Use const for constant arrays
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
` (5 preceding siblings ...)
2025-02-26 14:17 ` [PATCH v2 6/9] usb: storage: realtek_cr: Use const for constant arrays Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 8/9] usb: storage: sddr55: " Jonathan Neuschäfer via B4 Relay
` (2 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
The nand_flash_ids, inquiry_response, and mode_page_01 arrays are only
read, not modified.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/sddr09.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index d21ce3466e25842757b3e278d522c55b7c1f19de..e66b920e99e25c90b581ff1f3eae16ed0cfd903c 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -144,7 +144,7 @@ static inline char *nand_flash_manufacturer(int manuf_id) {
* 256 MB NAND flash has a 5-byte ID with 2nd byte 0xaa, 0xba, 0xca or 0xda.
*/
-static struct nand_flash_dev nand_flash_ids[] = {
+static const struct nand_flash_dev nand_flash_ids[] = {
/* NAND flash */
{ 0x6e, 20, 8, 4, 8, 2}, /* 1 MB */
{ 0xe8, 20, 8, 4, 8, 2}, /* 1 MB */
@@ -169,7 +169,7 @@ static struct nand_flash_dev nand_flash_ids[] = {
{ 0,}
};
-static struct nand_flash_dev *
+static const struct nand_flash_dev *
nand_find_id(unsigned char id) {
int i;
@@ -1133,9 +1133,9 @@ sddr09_reset(struct us_data *us) {
}
#endif
-static struct nand_flash_dev *
+static const struct nand_flash_dev *
sddr09_get_cardinfo(struct us_data *us, unsigned char flags) {
- struct nand_flash_dev *cardinfo;
+ const struct nand_flash_dev *cardinfo;
unsigned char deviceID[4];
char blurbtxt[256];
int result;
@@ -1545,12 +1545,12 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
struct sddr09_card_info *info;
- static unsigned char inquiry_response[8] = {
+ static const unsigned char inquiry_response[8] = {
0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00
};
/* note: no block descriptor support */
- static unsigned char mode_page_01[19] = {
+ static const unsigned char mode_page_01[19] = {
0x00, 0x0F, 0x00, 0x0, 0x0, 0x0, 0x00,
0x01, 0x0A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -1584,7 +1584,7 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
}
if (srb->cmnd[0] == READ_CAPACITY) {
- struct nand_flash_dev *cardinfo;
+ const struct nand_flash_dev *cardinfo;
sddr09_get_wp(us, info); /* read WP bit */
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 8/9] usb: storage: sddr55: Use const for constant arrays
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
` (6 preceding siblings ...)
2025-02-26 14:17 ` [PATCH v2 7/9] usb: storage: sddr09: " Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 14:17 ` [PATCH v2 9/9] usb: storage: shuttle_usbat: Use const for constant array Jonathan Neuschäfer via B4 Relay
2025-02-26 17:02 ` [PATCH v2 0/9] usb: storage: Mark various arrays as const Alan Stern
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
These arrays are only read, not modified.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/sddr55.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index d5cdff30f6f31f98d3d58ffcdd2426d7cd385cbb..b323f0a3626031905b946ce64ddf04539a6e3232 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -775,11 +775,11 @@ static void sddr55_card_info_destructor(void *extra) {
static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
{
int result;
- static unsigned char inquiry_response[8] = {
+ static const unsigned char inquiry_response[8] = {
0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00
};
// write-protected for now, no block descriptor support
- static unsigned char mode_page_01[20] = {
+ static const unsigned char mode_page_01[20] = {
0x0, 0x12, 0x00, 0x80, 0x0, 0x0, 0x0, 0x0,
0x01, 0x0A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v2 9/9] usb: storage: shuttle_usbat: Use const for constant array
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
` (7 preceding siblings ...)
2025-02-26 14:17 ` [PATCH v2 8/9] usb: storage: sddr55: " Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 14:17 ` Jonathan Neuschäfer via B4 Relay
2025-02-26 17:02 ` [PATCH v2 0/9] usb: storage: Mark various arrays as const Alan Stern
9 siblings, 0 replies; 12+ messages in thread
From: Jonathan Neuschäfer via B4 Relay @ 2025-02-26 14:17 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman
Cc: linux-usb, usb-storage, linux-kernel, Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.ne@posteo.net>
This array is only read, not modified.
Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
---
V2:
- new patch
---
drivers/usb/storage/shuttle_usbat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index c33cbf177e6fcaa80e0d2639594d1314c59f4950..27faa0ead11d1b0ee9e45ba6a3ee5bade8a416e4 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1683,7 +1683,7 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
struct usbat_info *info = (struct usbat_info *) (us->extra);
unsigned long block, blocks;
unsigned char *ptr = us->iobuf;
- static unsigned char inquiry_response[36] = {
+ static const unsigned char inquiry_response[36] = {
0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
};
--
2.48.0.rc1.219.gb6b6757d772
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH v2 0/9] usb: storage: Mark various arrays as const
2025-02-26 14:17 [PATCH v2 0/9] usb: storage: Mark various arrays as const Jonathan Neuschäfer via B4 Relay
` (8 preceding siblings ...)
2025-02-26 14:17 ` [PATCH v2 9/9] usb: storage: shuttle_usbat: Use const for constant array Jonathan Neuschäfer via B4 Relay
@ 2025-02-26 17:02 ` Alan Stern
2025-02-26 17:43 ` J. Neuschäfer
9 siblings, 1 reply; 12+ messages in thread
From: Alan Stern @ 2025-02-26 17:02 UTC (permalink / raw)
To: j.ne; +Cc: Greg Kroah-Hartman, linux-usb, usb-storage, linux-kernel
On Wed, Feb 26, 2025 at 03:17:22PM +0100, 'Jonathan Neuschäfer via B4 Relay' via USB Mass Storage on Linux wrote:
> While reading code, I noticed that some arrays in USB mass storage
> drivers are declared static but not const, even though they are not
> modified. This patchset marks them const.
>
> All patches were compile-tested.
>
> Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
> ---
> Changes in v2:
> - Add new patches 2-9
> - Use consistent authorship information
> - Link to v1: https://lore.kernel.org/r/20250225-misc-const-v1-1-121ff3b86437@posteo.net
The patches themselves look good, but I still think you should explain
in the patch descriptions why declaring these arrays const is worth
doing.
Merely saying _what_ you are doing isn't good enough. We can tell what
a patch does just by reading it. What we can't always tell is _why_ you
would want to do it. That is what needs to be explained.
The explanation doesn't have to be terribly long or detailed, but you
should not omit it entirely.
Alan Stern
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH v2 0/9] usb: storage: Mark various arrays as const
2025-02-26 17:02 ` [PATCH v2 0/9] usb: storage: Mark various arrays as const Alan Stern
@ 2025-02-26 17:43 ` J. Neuschäfer
0 siblings, 0 replies; 12+ messages in thread
From: J. Neuschäfer @ 2025-02-26 17:43 UTC (permalink / raw)
To: Alan Stern; +Cc: j.ne, Greg Kroah-Hartman, linux-usb, usb-storage, linux-kernel
On Wed, Feb 26, 2025 at 12:02:02PM -0500, Alan Stern wrote:
> On Wed, Feb 26, 2025 at 03:17:22PM +0100, 'Jonathan Neuschäfer via B4 Relay' via USB Mass Storage on Linux wrote:
> > While reading code, I noticed that some arrays in USB mass storage
> > drivers are declared static but not const, even though they are not
> > modified. This patchset marks them const.
> >
> > All patches were compile-tested.
> >
> > Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
> > ---
> > Changes in v2:
> > - Add new patches 2-9
> > - Use consistent authorship information
> > - Link to v1: https://lore.kernel.org/r/20250225-misc-const-v1-1-121ff3b86437@posteo.net
>
> The patches themselves look good, but I still think you should explain
> in the patch descriptions why declaring these arrays const is worth
> doing.
>
> Merely saying _what_ you are doing isn't good enough. We can tell what
> a patch does just by reading it. What we can't always tell is _why_ you
> would want to do it. That is what needs to be explained.
>
> The explanation doesn't have to be terribly long or detailed, but you
> should not omit it entirely.
Fair enough, I'll add such explanations to the patches.
Roughly, my motivations are:
- Moving data to read-only memory can prevent unintended modifications
and the hard-to-debug issue that might follow
- Const makes it easier for human readers to know what to expect
Best regards
^ permalink raw reply [flat|nested] 12+ messages in thread