* [PATCH] staging: greybus: use proper return type for wait_for_completion_timeout
@ 2019-04-27 3:27 Nicholas Mc Guire
2019-04-30 9:58 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Mc Guire @ 2019-04-27 3:27 UTC (permalink / raw)
To: David Lin
Cc: Johan Hovold, Alex Elder, Greg Kroah-Hartman, greybus-dev, devel,
linux-kernel, Nicholas Mc Guire
wait_for_completion_timeout() returns unsigned long (0 on timeout or
remaining jiffies) not int.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Problem located with experimental API conformance checking cocci script
Patch was compile-tested with: x86_64_defconfig + GREYBUS=m
Patch is against 5.1-rc6 (localversion-next is next-20190426)
drivers/staging/greybus/uart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index b3bffe9..ff18112 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -323,7 +323,7 @@ static int send_break(struct gb_tty *gb_tty, u8 state)
static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
{
- int ret;
+ unsigned long ret;
if (gb_tty->credits == GB_UART_FIRMWARE_CREDITS)
return 0;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: greybus: use proper return type for wait_for_completion_timeout
2019-04-27 3:27 [PATCH] staging: greybus: use proper return type for wait_for_completion_timeout Nicholas Mc Guire
@ 2019-04-30 9:58 ` Dan Carpenter
2019-04-30 12:59 ` Nicholas Mc Guire
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2019-04-30 9:58 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: David Lin, devel, Alex Elder, Greg Kroah-Hartman, Johan Hovold,
linux-kernel, greybus-dev
On Sat, Apr 27, 2019 at 05:27:25AM +0200, Nicholas Mc Guire wrote:
> wait_for_completion_timeout() returns unsigned long (0 on timeout or
> remaining jiffies) not int.
>
Yeah, but it's fine though because 10000 / 256 fits into int without a
problem.
I'm not sure this sort of patch is worth it when it's just a style
debate instead of a bugfix. I'm a little bit torn about this. In
Smatch, I run into this issue one in a while where Smatch doesn't know
if the timeout is less than int. Right now I hacked the DB to say that
these functions always return < INT_MAX.
Anyway, for sure the commit message should say that it's just a cleanup
and not a bugfix.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: greybus: use proper return type for wait_for_completion_timeout
2019-04-30 9:58 ` Dan Carpenter
@ 2019-04-30 12:59 ` Nicholas Mc Guire
0 siblings, 0 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2019-04-30 12:59 UTC (permalink / raw)
To: Dan Carpenter
Cc: Nicholas Mc Guire, David Lin, devel, Alex Elder,
Greg Kroah-Hartman, Johan Hovold, linux-kernel, greybus-dev
On Tue, Apr 30, 2019 at 12:58:21PM +0300, Dan Carpenter wrote:
> On Sat, Apr 27, 2019 at 05:27:25AM +0200, Nicholas Mc Guire wrote:
> > wait_for_completion_timeout() returns unsigned long (0 on timeout or
> > remaining jiffies) not int.
> >
>
> Yeah, but it's fine though because 10000 / 256 fits into int without a
> problem.
>
> I'm not sure this sort of patch is worth it when it's just a style
> debate instead of a bugfix. I'm a little bit torn about this. In
> Smatch, I run into this issue one in a while where Smatch doesn't know
> if the timeout is less than int. Right now I hacked the DB to say that
> these functions always return < INT_MAX.
>
> Anyway, for sure the commit message should say that it's just a cleanup
> and not a bugfix.
>
I know its not a functional bug its "only" an API violation - the problem
is more that code is often cut&past and at some point it may be a
problem or someoe expects a negative return value without that this evef
can occure.
But yes - the commit message should have stated that this non-conformance
in this case has no effect - will resend.
thx!
hofrat
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-30 13:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-27 3:27 [PATCH] staging: greybus: use proper return type for wait_for_completion_timeout Nicholas Mc Guire
2019-04-30 9:58 ` Dan Carpenter
2019-04-30 12:59 ` Nicholas Mc Guire
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.