Message ID | 20180309223211.20473-1-steve@sk2.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, 2018-03-09 at 23:32 +0100, Stephen Kitt wrote: > In preparation to enabling -Wvla, remove VLAs and replace them with > fixed-length arrays instead. > > scsi_dh_{alua,emc,rdac} use variable-length array declarations to > store command blocks, with the appropriate size as determined by > COMMAND_SIZE. This patch replaces these with fixed-sized arrays using > MAX_COMMAND_SIZE, so that the array size can be determined at compile > time. If COMMAND_SIZE() is evaluated at compile time, do we still need this patch? Thanks, Bart.
Hi Bart, On Fri, 9 Mar 2018 22:48:10 +0000, Bart Van Assche <Bart.VanAssche@wdc.com> wrote: > On Fri, 2018-03-09 at 23:32 +0100, Stephen Kitt wrote: > > In preparation to enabling -Wvla, remove VLAs and replace them with > > fixed-length arrays instead. > > > > scsi_dh_{alua,emc,rdac} use variable-length array declarations to > > store command blocks, with the appropriate size as determined by > > COMMAND_SIZE. This patch replaces these with fixed-sized arrays using > > MAX_COMMAND_SIZE, so that the array size can be determined at compile > > time. > > If COMMAND_SIZE() is evaluated at compile time, do we still need this patch? The two patches I sent were supposed to be alternative solutions; see https://marc.info/?l=linux-scsi&m=152063671005295&w=2 for the introduction (I seem to have messed up the headers, so the mails didn’t end up threaded properly). The MAX_COMMAND_SIZE approach is nice and simple, but I thought it worth eliminating scsi_command_size_tbl while I was at it... Regards, Stephen
On Sat, 2018-03-10 at 14:14 +0100, Stephen Kitt wrote: > The two patches I sent were supposed to be alternative solutions; see > https://marc.info/?l=linux-scsi&m=152063671005295&w=2 for the introduction (I > seem to have messed up the headers, so the mails didn’t end up threaded > properly). The two patches arrived in my inbox several minutes before the cover letter. In the e-mail header of the cover letter I found the following: X-Greylist: delayed 1810 seconds by postgrey-1.27 at vger.kernel.org; Fri, 09 Mar 2018 18:05:08 EST Does this mean that the delay happened due to vger server's anti-spam algorithm? Bart.
On Mon, 12 Mar 2018 15:41:26 +0000, Bart Van Assche <Bart.VanAssche@wdc.com> wrote: > On Sat, 2018-03-10 at 14:14 +0100, Stephen Kitt wrote: > > The two patches I sent were supposed to be alternative solutions; see > > https://marc.info/?l=linux-scsi&m=152063671005295&w=2 for the > > introduction (I seem to have messed up the headers, so the mails didn’t > > end up threaded properly). > > The two patches arrived in my inbox several minutes before the cover > letter. In the e-mail header of the cover letter I found the following: > > X-Greylist: delayed 1810 seconds by postgrey-1.27 at vger.kernel.org; Fri, > 09 Mar 2018 18:05:08 EST > > Does this mean that the delay happened due to vger server's anti-spam > algorithm? That’s right, the greylisting part of its anti-spam measures. Regards, Stephen
Stephen, > In preparation to enabling -Wvla, remove VLAs and replace them with > fixed-length arrays instead. > > scsi_dh_{alua,emc,rdac} use variable-length array declarations to > store command blocks, with the appropriate size as determined by > COMMAND_SIZE. This patch replaces these with fixed-sized arrays using > MAX_COMMAND_SIZE, so that the array size can be determined at compile > time. Applied to 4.17/scsi-queue. Thank you!
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 4b44325d1a82..982a52528a1c 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -138,12 +138,12 @@ static void release_port_group(struct kref *kref) static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff, int bufflen, struct scsi_sense_hdr *sshdr, int flags) { - u8 cdb[COMMAND_SIZE(MAINTENANCE_IN)]; + u8 cdb[MAX_COMMAND_SIZE]; int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; /* Prepare the command. */ - memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_IN)); + memset(cdb, 0x0, MAX_COMMAND_SIZE); cdb[0] = MAINTENANCE_IN; if (!(flags & ALUA_RTPG_EXT_HDR_UNSUPP)) cdb[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT; @@ -166,7 +166,7 @@ static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff, static int submit_stpg(struct scsi_device *sdev, int group_id, struct scsi_sense_hdr *sshdr) { - u8 cdb[COMMAND_SIZE(MAINTENANCE_OUT)]; + u8 cdb[MAX_COMMAND_SIZE]; unsigned char stpg_data[8]; int stpg_len = 8; int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | @@ -178,7 +178,7 @@ static int submit_stpg(struct scsi_device *sdev, int group_id, put_unaligned_be16(group_id, &stpg_data[6]); /* Prepare the command. */ - memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_OUT)); + memset(cdb, 0x0, MAX_COMMAND_SIZE); cdb[0] = MAINTENANCE_OUT; cdb[1] = MO_SET_TARGET_PGS; put_unaligned_be32(stpg_len, &cdb[6]); diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index 6a2792f3a37e..95c47909a58f 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -249,7 +249,7 @@ static int send_trespass_cmd(struct scsi_device *sdev, struct clariion_dh_data *csdev) { unsigned char *page22; - unsigned char cdb[COMMAND_SIZE(MODE_SELECT)]; + unsigned char cdb[MAX_COMMAND_SIZE]; int err, res = SCSI_DH_OK, len; struct scsi_sense_hdr sshdr; u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index 7af31a1247ee..d27fabae8ddd 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -533,7 +533,7 @@ static void send_mode_select(struct work_struct *work) int err = SCSI_DH_OK, retry_cnt = RDAC_RETRY_COUNT; struct rdac_queue_data *tmp, *qdata; LIST_HEAD(list); - unsigned char cdb[COMMAND_SIZE(MODE_SELECT_10)]; + unsigned char cdb[MAX_COMMAND_SIZE]; struct scsi_sense_hdr sshdr; unsigned int data_size; u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
In preparation to enabling -Wvla, remove VLAs and replace them with fixed-length arrays instead. scsi_dh_{alua,emc,rdac} use variable-length array declarations to store command blocks, with the appropriate size as determined by COMMAND_SIZE. This patch replaces these with fixed-sized arrays using MAX_COMMAND_SIZE, so that the array size can be determined at compile time. This was prompted by https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Stephen Kitt <steve@sk2.org> --- drivers/scsi/device_handler/scsi_dh_alua.c | 8 ++++---- drivers/scsi/device_handler/scsi_dh_emc.c | 2 +- drivers/scsi/device_handler/scsi_dh_rdac.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)