usb: storage: datafab: Use const for constant arrays

These arrays are only read, not modified.

Declaring data as const makes it easier to see what's going on, and can
prevent unintended writes through placement in a read-only section.

Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20250228-misc-const-v3-4-09b417ded9c4@posteo.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jonathan Neuschäfer 2025-02-28 16:11:19 +01:00 committed by Greg Kroah-Hartman
parent 734b0a7a5d
commit 6623c40bed
1 changed files with 7 additions and 7 deletions

View File

@ -319,7 +319,7 @@ static int datafab_determine_lun(struct us_data *us,
// //
// There might be a better way of doing this? // 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 *command = us->iobuf;
unsigned char *buf; unsigned char *buf;
int count = 0, rc; 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 // to the ATA spec, 'Sector Count' isn't used but the Windows driver
// sets this bit so we do too... // 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 *command = us->iobuf;
unsigned char *reply; unsigned char *reply;
int rc; int rc;
@ -437,16 +437,16 @@ static int datafab_handle_mode_sense(struct us_data *us,
struct scsi_cmnd * srb, struct scsi_cmnd * srb,
int sense_6) 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 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 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 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 0x1C, 0x6, 0, 0, 0, 0
}; };
unsigned char pc, page_code; unsigned char pc, page_code;
@ -550,7 +550,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
int rc; int rc;
unsigned long block, blocks; unsigned long block, blocks;
unsigned char *ptr = us->iobuf; 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 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
}; };