[PATCH v2] staging: axis-fifo: use size_t for write size calculations

Lucas Jeffrey posted 1 patch 3 hours ago
drivers/staging/axis-fifo/axis-fifo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH v2] staging: axis-fifo: use size_t for write size calculations
Posted by Lucas Jeffrey 3 hours ago
The write length is provided as size_t, but words_to_write and the
return value storage used narrower types (int and unsigned int).
Use size_t for the word count and ssize_t for the return value
to keep the types consistent with the write interface.

This is purely a cleanup. The VFS already bounds the write length
before the driver is called, so this does not change runtime behavior.

Signed-off-by: Lucas Jeffrey <luquijeffrey@gmail.com>
---
v2:
- Clarify that this is a cleanup.
- Mention that VFS already bounds write sizes.

 drivers/staging/axis-fifo/axis-fifo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 3aa2aa870ea9..d2b30b7b6845 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -214,9 +214,9 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
 			       size_t len, loff_t *off)
 {
 	struct axis_fifo *fifo = f->private_data;
-	unsigned int words_to_write;
+	size_t words_to_write;
 	u32 *txbuf;
-	int ret;
+	ssize_t ret;
 
 	words_to_write = len / sizeof(u32);
 
@@ -257,7 +257,7 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
 		goto end_unlock;
 	}
 
-	for (int i = 0; i < words_to_write; ++i)
+	for (size_t i = 0; i < words_to_write; ++i)
 		iowrite32(txbuf[i], fifo->base_addr + XLLF_TDFD_OFFSET);
 
 	iowrite32(len, fifo->base_addr + XLLF_TLR_OFFSET);
-- 
2.43.0