Skip to content

Commit

Permalink
block: scsi_ioctl: Avoid the use of one-element arrays
Browse files Browse the repository at this point in the history
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] KSPP#86

Build-tested-by: kernel test robot <[email protected]>
Link: https://lore.kernel.org/lkml/5f76f5d0.qJ4t%2FHWuRzSW7bTa%[email protected]/
Signed-off-by: Gustavo A. R. Silva <[email protected]>
  • Loading branch information
GustavoARSilva authored and intel-lab-lkp committed Oct 2, 2020
1 parent d296bc8 commit dcb49af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ struct compat_cdrom_generic_command {
unsigned char data_direction;
compat_int_t quiet;
compat_int_t timeout;
compat_caddr_t reserved[1];
compat_caddr_t unused;
};
#endif

Expand All @@ -673,7 +673,7 @@ static int scsi_get_cdrom_generic_arg(struct cdrom_generic_command *cgc,
.data_direction = cgc32.data_direction,
.quiet = cgc32.quiet,
.timeout = cgc32.timeout,
.reserved[0] = compat_ptr(cgc32.reserved[0]),
.unused = compat_ptr(cgc32.unused),
};
memcpy(&cgc->cmd, &cgc32.cmd, CDROM_PACKET_SIZE);
return 0;
Expand All @@ -698,7 +698,7 @@ static int scsi_put_cdrom_generic_arg(const struct cdrom_generic_command *cgc,
.data_direction = cgc->data_direction,
.quiet = cgc->quiet,
.timeout = cgc->timeout,
.reserved[0] = (uintptr_t)(cgc->reserved[0]),
.unused = (uintptr_t)(cgc->unused),
};
memcpy(&cgc32.cmd, &cgc->cmd, CDROM_PACKET_SIZE);

Expand Down
5 changes: 4 additions & 1 deletion include/uapi/linux/cdrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ struct cdrom_generic_command
unsigned char data_direction;
int quiet;
int timeout;
void __user *reserved[1]; /* unused, actually */
union {
void __user *reserved[1]; /* unused, actually */
void __user *unused;
};
};

/*
Expand Down

0 comments on commit dcb49af

Please sign in to comment.