scsi: ata: Use unsigned int for cmd's type in ioctls in scsi_host_template
Clang warns several times in the scsi subsystem (trimmed for brevity): drivers/scsi/hpsa.c:6209:7: warning: overflow converting case value to switch condition type (2147762695 to 18446744071562347015) [-Wswitch] case CCISS_GETBUSTYPES: ^ drivers/scsi/hpsa.c:6208:7: warning: overflow converting case value to switch condition type (2147762694 to 18446744071562347014) [-Wswitch] case CCISS_GETHEARTBEAT: ^ The root cause is that the _IOC macro can generate really large numbers, which don't fit into type 'int', which is used for the cmd parameter in the ioctls in scsi_host_template. My research into how GCC and Clang are handling this at a low level didn't prove fruitful. However, looking at the rest of the kernel tree, all ioctls use an 'unsigned int' for the cmd parameter, which will fit all of the _IOC values in the scsi/ata subsystems. Make that change because none of the ioctls expect a negative value for any command, it brings the ioctls inline with the reset of the kernel, and it removes ambiguity, which is never good when dealing with compilers. Link: https://github.com/ClangBuiltLinux/linux/issues/85 Link: https://github.com/ClangBuiltLinux/linux/issues/154 Link: https://github.com/ClangBuiltLinux/linux/issues/157 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Acked-by: Bradley Grove <bgrove@attotech.com> Acked-by: Don Brace <don.brace@microsemi.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Šī revīzija ir iekļauta:

revīziju iesūtīja
Martin K. Petersen

vecāks
42fb055a57
revīzija
6f4e626fb0
@@ -1274,7 +1274,7 @@ int esas2r_write_params(struct esas2r_adapter *a, struct esas2r_request *rq,
|
||||
|
||||
|
||||
/* This function only cares about ATTO-specific ioctls (atto_express_ioctl) */
|
||||
int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
|
||||
int esas2r_ioctl_handler(void *hostdata, unsigned int cmd, void __user *arg)
|
||||
{
|
||||
struct atto_express_ioctl *ioctl = NULL;
|
||||
struct esas2r_adapter *a;
|
||||
@@ -1292,9 +1292,8 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
|
||||
ioctl = memdup_user(arg, sizeof(struct atto_express_ioctl));
|
||||
if (IS_ERR(ioctl)) {
|
||||
esas2r_log(ESAS2R_LOG_WARN,
|
||||
"ioctl_handler access_ok failed for cmd %d, "
|
||||
"address %p", cmd,
|
||||
arg);
|
||||
"ioctl_handler access_ok failed for cmd %u, address %p",
|
||||
cmd, arg);
|
||||
return PTR_ERR(ioctl);
|
||||
}
|
||||
|
||||
@@ -1493,7 +1492,7 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
|
||||
ioctl_done:
|
||||
|
||||
if (err < 0) {
|
||||
esas2r_log(ESAS2R_LOG_WARN, "err %d on ioctl cmd %d", err,
|
||||
esas2r_log(ESAS2R_LOG_WARN, "err %d on ioctl cmd %u", err,
|
||||
cmd);
|
||||
|
||||
switch (err) {
|
||||
@@ -1518,9 +1517,8 @@ ioctl_done:
|
||||
err = __copy_to_user(arg, ioctl, sizeof(struct atto_express_ioctl));
|
||||
if (err != 0) {
|
||||
esas2r_log(ESAS2R_LOG_WARN,
|
||||
"ioctl_handler copy_to_user didn't copy "
|
||||
"everything (err %d, cmd %d)", err,
|
||||
cmd);
|
||||
"ioctl_handler copy_to_user didn't copy everything (err %d, cmd %u)",
|
||||
err, cmd);
|
||||
kfree(ioctl);
|
||||
|
||||
return -EFAULT;
|
||||
@@ -1531,7 +1529,7 @@ ioctl_done:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int esas2r_ioctl(struct scsi_device *sd, int cmd, void __user *arg)
|
||||
int esas2r_ioctl(struct scsi_device *sd, unsigned int cmd, void __user *arg)
|
||||
{
|
||||
return esas2r_ioctl_handler(sd->host->hostdata, cmd, arg);
|
||||
}
|
||||
|
Atsaukties uz šo jaunā problēmā
Block a user