scsi: device_handler: remove VLAs
authorStephen Kitt <steve@sk2.org>
Fri, 9 Mar 2018 22:32:11 +0000 (23:32 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Mar 2018 02:37:20 +0000 (22:37 -0400)
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>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/device_handler/scsi_dh_alua.c
drivers/scsi/device_handler/scsi_dh_emc.c
drivers/scsi/device_handler/scsi_dh_rdac.c

index 022e421c218513055f0e4033611736523751cbb6..c3483d811824ee4ade79d6089e2f49ed75986ff7 100644 (file)
@@ -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]);
index 6a2792f3a37eeb10a0d010707b88f099e327b394..95c47909a58f33409822b66da4b097700736526a 100644 (file)
@@ -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 |
index 7af31a1247eee5ba020d3d3b1fea7e418d6277e8..d27fabae8ddd9c2e045203ada3d3673799441ce8 100644 (file)
@@ -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 |