Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: scsi_ioctl: Avoid the use of one-element arrays

One-element arrays are being deprecated[1]. Replace the one-element array
with a simple object of type compat_caddr_t: 'compat_caddr_t unused'[2],
once it seems this field is actually never used.

Also, update struct cdrom_generic_command in UAPI by adding an
anonimous union to avoid using the one-element array _reserved_.

[1] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
[2] https://github.com/KSPP/linux/issues/86

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/lkml/5f76f5d0.qJ4t%2FHWuRzSW7bTa%25lkp@intel.com/
Build-tested-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Gustavo A. R. Silva and committed by
Jens Axboe
f5ace5ef 99ba84c5

+7 -4
+3 -3
block/scsi_ioctl.c
··· 651 651 unsigned char data_direction; 652 652 compat_int_t quiet; 653 653 compat_int_t timeout; 654 - compat_caddr_t reserved[1]; 654 + compat_caddr_t unused; 655 655 }; 656 656 #endif 657 657 ··· 673 673 .data_direction = cgc32.data_direction, 674 674 .quiet = cgc32.quiet, 675 675 .timeout = cgc32.timeout, 676 - .reserved[0] = compat_ptr(cgc32.reserved[0]), 676 + .unused = compat_ptr(cgc32.unused), 677 677 }; 678 678 memcpy(&cgc->cmd, &cgc32.cmd, CDROM_PACKET_SIZE); 679 679 return 0; ··· 698 698 .data_direction = cgc->data_direction, 699 699 .quiet = cgc->quiet, 700 700 .timeout = cgc->timeout, 701 - .reserved[0] = (uintptr_t)(cgc->reserved[0]), 701 + .unused = (uintptr_t)(cgc->unused), 702 702 }; 703 703 memcpy(&cgc32.cmd, &cgc->cmd, CDROM_PACKET_SIZE); 704 704
+4 -1
include/uapi/linux/cdrom.h
··· 289 289 unsigned char data_direction; 290 290 int quiet; 291 291 int timeout; 292 - void __user *reserved[1]; /* unused, actually */ 292 + union { 293 + void __user *reserved[1]; /* unused, actually */ 294 + void __user *unused; 295 + }; 293 296 }; 294 297 295 298 /*