[PATCH v2] staging: gpib: use int type to store negative error codes

Qianfeng Rong posted 1 patch 1 month, 1 week ago
drivers/staging/gpib/gpio/gpib_bitbang.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] staging: gpib: use int type to store negative error codes
Posted by Qianfeng Rong 1 month, 1 week ago
The "ret" variable is used to store the return from bb_write() returns
either zero on success or negative error codes on failure.  Storing the
error codes in size_t which is an unsigned long, doesn't cause an issue
at runtime but it's ugly as pants.  Change "ret" from size_t to int
type.  No effect on runtime.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
v2: Modified commit message as suggested by Dan.
---
 drivers/staging/gpib/gpio/gpib_bitbang.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/gpib/gpio/gpib_bitbang.c b/drivers/staging/gpib/gpio/gpib_bitbang.c
index 22a55f3f794d..374cd61355e9 100644
--- a/drivers/staging/gpib/gpio/gpib_bitbang.c
+++ b/drivers/staging/gpib/gpio/gpib_bitbang.c
@@ -726,7 +726,7 @@ static irqreturn_t bb_SRQ_interrupt(int irq, void *arg)
 static int bb_command(struct gpib_board *board, u8 *buffer,
 		      size_t length, size_t *bytes_written)
 {
-	size_t ret;
+	int ret;
 	struct bb_priv *priv = board->private_data;
 	int i;
 
-- 
2.34.1
Re: [PATCH v2] staging: gpib: use int type to store negative error codes
Posted by Dan Carpenter 1 month, 1 week ago
On Tue, Aug 26, 2025 at 08:32:01PM +0800, Qianfeng Rong wrote:
> The "ret" variable is used to store the return from bb_write() returns
> either zero on success or negative error codes on failure.  Storing the
> error codes in size_t which is an unsigned long, doesn't cause an issue
> at runtime but it's ugly as pants.  Change "ret" from size_t to int
> type.  No effect on runtime.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
> v2: Modified commit message as suggested by Dan.

Awesome.  Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

regards,
dan carpenter