History

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.

Nathan Chancellor committed 7 years ago

Commit 6f4e6261 parent 42fb05519 files · +54 −44Browse files

Showing the changes to include/linux (1 of 19 files). Show all

Unified · Split

include/linux/libata.h+3−2
@@ -1122,10 +1122,11 @@ extern int ata_host_activate(struct ata_host *host, int irq, · 1121 unmodified lines
1122extern void ata_host_detach(struct ata_host *host);1122extern void ata_host_detach(struct ata_host *host);
1123extern void ata_host_init(struct ata_host *, struct device *, struct ata_port_operations *);1123extern void ata_host_init(struct ata_host *, struct device *, struct ata_port_operations *);
1124extern int ata_scsi_detect(struct scsi_host_template *sht);1124extern int ata_scsi_detect(struct scsi_host_template *sht);
1125extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);1125extern int ata_scsi_ioctl(struct scsi_device *dev, unsigned int cmd,
1126 void __user *arg);
1126extern int ata_scsi_queuecmd(struct Scsi_Host *h, struct scsi_cmnd *cmd);1127extern int ata_scsi_queuecmd(struct Scsi_Host *h, struct scsi_cmnd *cmd);
1127extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,1128extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,
1128 int cmd, void __user *arg);1129 unsigned int cmd, void __user *arg);
1129extern void ata_sas_port_destroy(struct ata_port *);1130extern void ata_sas_port_destroy(struct ata_port *);
1130extern struct ata_port *ata_sas_port_alloc(struct ata_host *,1131extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
1131 struct ata_port_info *, struct Scsi_Host *);1132 struct ata_port_info *, struct Scsi_Host *);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t