diff mbox

scsi: libosd: Remove VLA usage

Message ID 20180502225545.GA45533@beast (mailing list archive)
State Accepted
Headers show

Commit Message

Kees Cook May 2, 2018, 10:55 p.m. UTC
On the quest to remove all VLAs from the kernel[1] this rearranges the
code to avoid a VLA warning under -Wvla (gcc doesn't recognize "const"
variables as not triggering VLA creation). Additionally cleans up variable
naming to avoid 80 character column limit.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/scsi/osd/osd_initiator.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Boaz Harrosh May 13, 2018, 9:04 a.m. UTC | #1
On 03/05/18 01:55, Kees Cook wrote:
> On the quest to remove all VLAs from the kernel[1] this rearranges the
> code to avoid a VLA warning under -Wvla (gcc doesn't recognize "const"
> variables as not triggering VLA creation). Additionally cleans up variable
> naming to avoid 80 character column limit.
> 
> [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
> 

ACK-BY: Boaz Harrosh <ooo@electrozaur.com>

> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  drivers/scsi/osd/osd_initiator.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
> index e18877177f1b..917a86a2ae8c 100644
> --- a/drivers/scsi/osd/osd_initiator.c
> +++ b/drivers/scsi/osd/osd_initiator.c
> @@ -1842,14 +1842,14 @@ int osd_req_decode_sense_full(struct osd_request *or,
>  		case osd_sense_response_integrity_check:
>  		{
>  			struct osd_sense_response_integrity_check_descriptor
> -				*osricd = cur_descriptor;
> -			const unsigned len =
> -					  sizeof(osricd->integrity_check_value);
> -			char key_dump[len*4 + 2]; /* 2nibbles+space+ASCII */
> -
> -			hex_dump_to_buffer(osricd->integrity_check_value, len,
> -				       32, 1, key_dump, sizeof(key_dump), true);
> -			OSD_SENSE_PRINT2("response_integrity [%s]\n", key_dump);
> +				*d = cur_descriptor;
> +			/* 2nibbles+space+ASCII */
> +			char dump[sizeof(d->integrity_check_value) * 4 + 2];
> +
> +			hex_dump_to_buffer(d->integrity_check_value,
> +					sizeof(d->integrity_check_value),
> +					32, 1, dump, sizeof(dump), true);
> +			OSD_SENSE_PRINT2("response_integrity [%s]\n", dump);
>  		}
>  		case osd_sense_attribute_identification:
>  		{
>
Martin K. Petersen May 15, 2018, 2:33 a.m. UTC | #2
Kees,

> On the quest to remove all VLAs from the kernel[1] this rearranges the
> code to avoid a VLA warning under -Wvla (gcc doesn't recognize "const"
> variables as not triggering VLA creation). Additionally cleans up variable
> naming to avoid 80 character column limit.

Applied to 4.18/scsi-queue. Thanks!
diff mbox

Patch

diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index e18877177f1b..917a86a2ae8c 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -1842,14 +1842,14 @@  int osd_req_decode_sense_full(struct osd_request *or,
 		case osd_sense_response_integrity_check:
 		{
 			struct osd_sense_response_integrity_check_descriptor
-				*osricd = cur_descriptor;
-			const unsigned len =
-					  sizeof(osricd->integrity_check_value);
-			char key_dump[len*4 + 2]; /* 2nibbles+space+ASCII */
-
-			hex_dump_to_buffer(osricd->integrity_check_value, len,
-				       32, 1, key_dump, sizeof(key_dump), true);
-			OSD_SENSE_PRINT2("response_integrity [%s]\n", key_dump);
+				*d = cur_descriptor;
+			/* 2nibbles+space+ASCII */
+			char dump[sizeof(d->integrity_check_value) * 4 + 2];
+
+			hex_dump_to_buffer(d->integrity_check_value,
+					sizeof(d->integrity_check_value),
+					32, 1, dump, sizeof(dump), true);
+			OSD_SENSE_PRINT2("response_integrity [%s]\n", dump);
 		}
 		case osd_sense_attribute_identification:
 		{