From: Stephen Kitt Date: Thu, 8 Mar 2018 20:51:58 +0000 (+0100) Subject: scsi: aic7xxx: aic79xx: remove VLAs X-Git-Tag: v4.19~1290^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88b13609afca8ed2992c107c15326b4a8142e5da;p=platform%2Fkernel%2Flinux-rpi.git scsi: aic7xxx: aic79xx: remove VLAs In preparation to enabling -Wvla, remove VLAs and replace them with fixed-length arrays instead. The arrays fixed here, using the number of constant sections, aren't really VLAs, but they appear so to the compiler. Replace the array sizes with a pre-processor-level constant instead using ARRAY_SIZE. This was prompted by https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Stephen Kitt Reviewed-by: Kees Cook Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index b560f39..034f4ee 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -9338,9 +9338,9 @@ ahd_dumpseq(struct ahd_softc* ahd) static void ahd_loadseq(struct ahd_softc *ahd) { - struct cs cs_table[num_critical_sections]; - u_int begin_set[num_critical_sections]; - u_int end_set[num_critical_sections]; + struct cs cs_table[NUM_CRITICAL_SECTIONS]; + u_int begin_set[NUM_CRITICAL_SECTIONS]; + u_int end_set[NUM_CRITICAL_SECTIONS]; const struct patch *cur_patch; u_int cs_count; u_int cur_cs; @@ -9456,7 +9456,7 @@ ahd_loadseq(struct ahd_softc *ahd) * Move through the CS table until we find a CS * that might apply to this instruction. */ - for (; cur_cs < num_critical_sections; cur_cs++) { + for (; cur_cs < NUM_CRITICAL_SECTIONS; cur_cs++) { if (critical_sections[cur_cs].end <= i) { if (begin_set[cs_count] == TRUE && end_set[cs_count] == FALSE) { diff --git a/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped b/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped index 4b51e23..fd64a95 100644 --- a/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped +++ b/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped @@ -1186,5 +1186,4 @@ static const struct cs { { 759, 763 } }; -static const int num_critical_sections = sizeof(critical_sections) - / sizeof(*critical_sections); +#define NUM_CRITICAL_SECTIONS ARRAY_SIZE(critical_sections) diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index 6612ff3..e97ecea 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -6848,9 +6848,9 @@ ahc_dumpseq(struct ahc_softc* ahc) static int ahc_loadseq(struct ahc_softc *ahc) { - struct cs cs_table[num_critical_sections]; - u_int begin_set[num_critical_sections]; - u_int end_set[num_critical_sections]; + struct cs cs_table[NUM_CRITICAL_SECTIONS]; + u_int begin_set[NUM_CRITICAL_SECTIONS]; + u_int end_set[NUM_CRITICAL_SECTIONS]; const struct patch *cur_patch; u_int cs_count; u_int cur_cs; @@ -6915,7 +6915,7 @@ ahc_loadseq(struct ahc_softc *ahc) * Move through the CS table until we find a CS * that might apply to this instruction. */ - for (; cur_cs < num_critical_sections; cur_cs++) { + for (; cur_cs < NUM_CRITICAL_SECTIONS; cur_cs++) { if (critical_sections[cur_cs].end <= i) { if (begin_set[cs_count] == TRUE && end_set[cs_count] == FALSE) { diff --git a/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped b/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped index 07e93fb..f37362b 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped +++ b/drivers/scsi/aic7xxx/aic7xxx_seq.h_shipped @@ -1304,5 +1304,4 @@ static const struct cs { { 875, 877 } }; -static const int num_critical_sections = sizeof(critical_sections) - / sizeof(*critical_sections); +#define NUM_CRITICAL_SECTIONS ARRAY_SIZE(critical_sections) diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm.c b/drivers/scsi/aic7xxx/aicasm/aicasm.c index 21ac265..5f474e4 100644 --- a/drivers/scsi/aic7xxx/aicasm/aicasm.c +++ b/drivers/scsi/aic7xxx/aicasm/aicasm.c @@ -451,8 +451,7 @@ output_code() fprintf(ofile, "\n};\n\n"); fprintf(ofile, -"static const int num_critical_sections = sizeof(critical_sections)\n" -" / sizeof(*critical_sections);\n"); + "#define NUM_CRITICAL_SECTIONS ARRAY_SIZE(critical_sections)\n"); fprintf(stderr, "%s: %d instructions used\n", appname, instrcount); }