[PATCH] treewide: use an unsigned type for ioctl commands

Ahmad Fatoum a.fatoum at pengutronix.de
Fri May 17 00:49:00 PDT 2024


Linux & BSD define the ioctl command parameter to be always unsigned.
POSIX differs and uses a signed integer instead, but as we are importing
Linux code, it makes sense to use the same signedness to avoid false
positive warnings about sign-extended constants that get truncated.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 commands/nand.c                | 2 +-
 drivers/firmware/qemu_fw_cfg.c | 2 +-
 drivers/misc/jtag.c            | 2 +-
 drivers/misc/storage-by-uuid.c | 2 +-
 drivers/mtd/core.c             | 2 +-
 drivers/mtd/mtd.h              | 2 +-
 drivers/mtd/ubi/barebox.c      | 4 ++--
 drivers/video/fb.c             | 2 +-
 fs/devfs-core.c                | 2 +-
 fs/devfs.c                     | 2 +-
 fs/fs.c                        | 2 +-
 fs/uimagefs.c                  | 2 +-
 include/driver.h               | 4 ++--
 include/fs.h                   | 2 +-
 include/linux/fs.h             | 2 +-
 include/sys/ioctl.h            | 2 +-
 16 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/commands/nand.c b/commands/nand.c
index d07444aee0be..d80ec24a7b92 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -102,7 +102,7 @@ static int do_nand(int argc, char *argv[])
 
 	if (command == NAND_MARKBAD || command == NAND_MARKGOOD) {
 		const char *str;
-		int ctl;
+		unsigned int ctl;
 
 		if (command == NAND_MARKBAD) {
 			str = "bad";
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 3f129a2c1e02..71af4d973cd3 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -75,7 +75,7 @@ static void fw_cfg_io_cleanup(struct fw_cfg *fw_cfg)
 	release_region(fw_cfg->iores);
 }
 
-static int fw_cfg_ioctl(struct cdev *cdev, int request, void *buf)
+static int fw_cfg_ioctl(struct cdev *cdev, unsigned int request, void *buf)
 {
 	struct fw_cfg *fw_cfg = to_fw_cfg(cdev);
 	int ret = 0;
diff --git a/drivers/misc/jtag.c b/drivers/misc/jtag.c
index e884e58bac0f..d7cd2dabf7bc 100644
--- a/drivers/misc/jtag.c
+++ b/drivers/misc/jtag.c
@@ -80,7 +80,7 @@ static void jtag_output(const struct jtag_platdata *pdata,
 	}
 }
 
-static int jtag_ioctl(struct cdev *inode, int cmd, void *arg)
+static int jtag_ioctl(struct cdev *inode, unsigned int cmd, void *arg)
 {
 	int ret = 0;
 	struct jtag_info *info = (struct jtag_info *)inode->priv;
diff --git a/drivers/misc/storage-by-uuid.c b/drivers/misc/storage-by-uuid.c
index 5548f477a4c8..db15b64d7dcf 100644
--- a/drivers/misc/storage-by-uuid.c
+++ b/drivers/misc/storage-by-uuid.c
@@ -33,7 +33,7 @@ static ssize_t sbu_write(struct cdev *cdev, const void *buf, size_t count, loff_
 	return cdev_write(sbu->rcdev, buf, count, offset, flags);
 }
 
-static int sbu_ioctl(struct cdev *cdev, int request, void *buf)
+static int sbu_ioctl(struct cdev *cdev, unsigned int request, void *buf)
 {
 	struct sbu *sbu = cdev->priv;
 
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index ec2c3ff7bb41..562443275fe6 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -243,7 +243,7 @@ static int mtd_op_protect(struct cdev *cdev, size_t count, loff_t offset, int pr
 
 #endif /* CONFIG_MTD_WRITE */
 
-int mtd_ioctl(struct cdev *cdev, int request, void *buf)
+int mtd_ioctl(struct cdev *cdev, unsigned int request, void *buf)
 {
 	int ret = 0;
 	struct mtd_info *mtd = cdev->priv;
diff --git a/drivers/mtd/mtd.h b/drivers/mtd/mtd.h
index 725731e6266d..c0af4f39d4c4 100644
--- a/drivers/mtd/mtd.h
+++ b/drivers/mtd/mtd.h
@@ -30,4 +30,4 @@ struct cdev;
  */
 void mtdcore_add_hook(struct mtddev_hook *hook);
 
-int mtd_ioctl(struct cdev *cdev, int request, void *buf);
+int mtd_ioctl(struct cdev *cdev, unsigned int request, void *buf);
diff --git a/drivers/mtd/ubi/barebox.c b/drivers/mtd/ubi/barebox.c
index 7ae5b4c4b4ff..5d7bf69cc7c2 100644
--- a/drivers/mtd/ubi/barebox.c
+++ b/drivers/mtd/ubi/barebox.c
@@ -178,7 +178,7 @@ static int ubi_volume_cdev_truncate(struct cdev *cdev, size_t size)
 	return 0;
 }
 
-static int ubi_volume_cdev_ioctl(struct cdev *cdev, int cmd, void *buf)
+static int ubi_volume_cdev_ioctl(struct cdev *cdev, unsigned int cmd, void *buf)
 {
 	struct ubi_volume_cdev_priv *priv = cdev->priv;
 	struct ubi_device *ubi = priv->ubi;
@@ -450,7 +450,7 @@ int ubi_api_rename_volumes(int ubi_num, struct ubi_rnvol_req *req)
 	return err;
 }
 
-static int ubi_cdev_ioctl(struct cdev *cdev, int cmd, void *buf)
+static int ubi_cdev_ioctl(struct cdev *cdev, unsigned int cmd, void *buf)
 {
 	struct ubi_device *ubi = cdev->priv;
 
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 6f412d62c434..a752c114e2d0 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -9,7 +9,7 @@
 #include <fs.h>
 #include <init.h>
 
-static int fb_ioctl(struct cdev* cdev, int req, void *data)
+static int fb_ioctl(struct cdev* cdev, unsigned int req, void *data)
 {
 	struct fb_info *info = cdev->priv;
 	struct fb_info **fb;
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 21e5c2dc969a..ed445fbd4712 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -261,7 +261,7 @@ int cdev_flush(struct cdev *cdev)
 	return cdev->ops->flush(cdev);
 }
 
-int cdev_ioctl(struct cdev *cdev, int request, void *buf)
+int cdev_ioctl(struct cdev *cdev, unsigned int request, void *buf)
 {
 	if (!cdev->ops->ioctl)
 		return -EINVAL;
diff --git a/fs/devfs.c b/fs/devfs.c
index f5bad5aa9bf2..9dbfa91b1d9f 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -124,7 +124,7 @@ static int devfs_flush(struct device *_dev, FILE *f)
 	return cdev_flush(cdev);
 }
 
-static int devfs_ioctl(struct device *_dev, FILE *f, int request, void *buf)
+static int devfs_ioctl(struct device *_dev, FILE *f, unsigned int request, void *buf)
 {
 	struct cdev *cdev = f->priv;
 
diff --git a/fs/fs.c b/fs/fs.c
index 3a5298649cc1..656434f67ffa 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -381,7 +381,7 @@ int ftruncate(int fd, loff_t length)
 	return 0;
 }
 
-int ioctl(int fd, int request, void *buf)
+int ioctl(int fd, unsigned int request, void *buf)
 {
 	struct fs_driver *fsdrv;
 	FILE *f = fd_to_file(fd, false);
diff --git a/fs/uimagefs.c b/fs/uimagefs.c
index 735a35e5000f..6913685c0cf6 100644
--- a/fs/uimagefs.c
+++ b/fs/uimagefs.c
@@ -181,7 +181,7 @@ static int uimagefs_stat(struct device *dev, const char *filename,
 	return 0;
 }
 
-static int uimagefs_ioctl(struct device *dev, FILE *f, int request, void *buf)
+static int uimagefs_ioctl(struct device *dev, FILE *f, unsigned int request, void *buf)
 {
 	struct uimagefs_handle *priv = dev->priv;
 
diff --git a/include/driver.h b/include/driver.h
index c8eb7605e768..1c263158181f 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -441,7 +441,7 @@ struct cdev_operations {
 	/*! Called in response of write to this device. Required */
 	ssize_t (*write)(struct cdev*, const void* buf, size_t count, loff_t offset, ulong flags);
 
-	int (*ioctl)(struct cdev*, int, void *);
+	int (*ioctl)(struct cdev*, unsigned int, void *);
 	int (*lseek)(struct cdev*, loff_t);
 	int (*open)(struct cdev*, unsigned long flags);
 	int (*close)(struct cdev*);
@@ -528,7 +528,7 @@ int cdev_close(struct cdev *cdev);
 int cdev_flush(struct cdev *cdev);
 ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags);
 ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags);
-int cdev_ioctl(struct cdev *cdev, int cmd, void *buf);
+int cdev_ioctl(struct cdev *cdev, unsigned int cmd, void *buf);
 int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset);
 int cdev_lseek(struct cdev*, loff_t);
 int cdev_protect(struct cdev*, size_t count, loff_t offset, int prot);
diff --git a/include/fs.h b/include/fs.h
index 70903142e89b..f87c4c40273f 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -56,7 +56,7 @@ struct fs_driver {
 	int (*flush)(struct device *dev, FILE *f);
 	int (*lseek)(struct device *dev, FILE *f, loff_t pos);
 
-	int (*ioctl)(struct device *dev, FILE *f, int request, void *buf);
+	int (*ioctl)(struct device *dev, FILE *f, unsigned int request, void *buf);
 	int (*erase)(struct device *dev, FILE *f, loff_t count,
 			loff_t offset);
 	int (*protect)(struct device *dev, FILE *f, size_t count,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index fc1357137ade..b1161c4a881f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -471,7 +471,7 @@ struct file_operations {
 	int (*iterate) (struct file *, struct dir_context *);
 	ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
 	ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
-	int (*ioctl) (struct file *, int request, void *buf);
+	int (*ioctl) (struct file *, unsigned int request, void *buf);
 	int (*truncate) (struct file *, loff_t);
 };
 
diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
index 5a949f1f3c0c..5b5ca1c37389 100644
--- a/include/sys/ioctl.h
+++ b/include/sys/ioctl.h
@@ -3,6 +3,6 @@
 #ifndef __SYS_IOCTL_H
 #define __SYS_IOCTL_H
 
-int ioctl(int fd, int request, void *buf);
+int ioctl(int fd, unsigned int request, void *buf);
 
 #endif /* __SYS_IOCTL_H */
-- 
2.39.2




More information about the barebox mailing list