2017-07-19 03:00:42

by Joseph Wright

[permalink] [raw]
Subject: [PATCH 0/2] Staging: pi433: fix sparse warnings

Two patches included to fix warnings found with sparse.

Joseph Wright (2):
Staging: pi433: declare functions static
Staging: pi433: check error after kthread_run()

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

--
2.9.3


2017-07-19 03:00:49

by Joseph Wright

[permalink] [raw]
Subject: [PATCH 2/2] Staging: pi433: check error after kthread_run()

Error should be checked with IS_ERR after calling kthread_run()
instead of comparing the returned pointer to an int.

Found by sparse warning:

incompatible types for operation (<)
left side has type struct task_struct *tx_task_struct
right side has type int

Signed-off-by: Joseph Wright <[email protected]>
---
drivers/staging/pi433/pi433_if.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 46461b4..4f724a5 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1152,7 +1152,7 @@ static int pi433_probe(struct spi_device *spi)
device->tx_task_struct = kthread_run(pi433_tx_thread,
device,
"pi433_tx_task");
- if (device->tx_task_struct < 0)
+ if (IS_ERR(device->tx_task_struct))
{
dev_dbg(device->dev, "start of send thread failed");
goto send_thread_failed;
--
2.9.3

2017-07-19 03:00:48

by Joseph Wright

[permalink] [raw]
Subject: [PATCH 1/2] Staging: pi433: declare functions static

Declare functions static to fix sparse warnings:

warning: symbol 'pi433_receive' was not declared. Should it be static?
warning: symbol 'pi433_tx_thread' was not declared. Should it be static?

Signed-off-by: Joseph Wright <[email protected]>
---
drivers/staging/pi433/pi433_if.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 1bc478a..46461b4 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -313,7 +313,7 @@ pi433_start_rx(struct pi433_device *dev)

/*-------------------------------------------------------------------------*/

-int
+static int
pi433_receive(void *data)
{
struct pi433_device *dev = data;
@@ -463,7 +463,7 @@ pi433_receive(void *data)
return bytes_total;
}

-int
+static int
pi433_tx_thread(void *data)
{
struct pi433_device *device = data;
--
2.9.3

2017-07-19 19:41:35

by Marcus Wolf

[permalink] [raw]
Subject: Re: [PATCH 2/2] Staging: pi433: check error after kthread_run()

Hi Joseph,

tested your patch and didn't observe a problem.

Thanks for your help :-)

Marcus

> Joseph Wright <[email protected]> hat am 16. Juli 2017 um 16:48
> geschrieben:
>
>
> Error should be checked with IS_ERR after calling kthread_run()
> instead of comparing the returned pointer to an int.
>
> Found by sparse warning:
>
> incompatible types for operation (<)
> left side has type struct task_struct *tx_task_struct
> right side has type int
>
> Signed-off-by: Joseph Wright <[email protected]>
> ---
> drivers/staging/pi433/pi433_if.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/pi433/pi433_if.c
> b/drivers/staging/pi433/pi433_if.c
> index 46461b4..4f724a5 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -1152,7 +1152,7 @@ static int pi433_probe(struct spi_device *spi)
> device->tx_task_struct = kthread_run(pi433_tx_thread,
> device,
> "pi433_tx_task");
> - if (device->tx_task_struct < 0)
> + if (IS_ERR(device->tx_task_struct))
> {
> dev_dbg(device->dev, "start of send thread failed");
> goto send_thread_failed;
> --
> 2.9.3
>
>

2017-07-20 11:04:46

by Marcus Wolf

[permalink] [raw]
Subject: Re: [PATCH 1/2] Staging: pi433: declare functions static

Reviewed-by: Marcus Wolf <[email protected]>

Am So, 16.07.2017, 16:48 schrieb Joseph Wright:
> Declare functions static to fix sparse warnings:
>
> warning: symbol 'pi433_receive' was not declared. Should it be static?
> warning: symbol 'pi433_tx_thread' was not declared. Should it be static?
>
> Signed-off-by: Joseph Wright <[email protected]>
> ---
> drivers/staging/pi433/pi433_if.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
> index 1bc478a..46461b4 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -313,7 +313,7 @@ pi433_start_rx(struct pi433_device *dev)
>
> /*-------------------------------------------------------------------------*/
>
> -int
> +static int
> pi433_receive(void *data)
> {
> struct pi433_device *dev = data;
> @@ -463,7 +463,7 @@ pi433_receive(void *data)
> return bytes_total;
> }
>
> -int
> +static int
> pi433_tx_thread(void *data)
> {
> struct pi433_device *device = data;
> --
> 2.9.3
>
>
>

2017-07-20 11:05:24

by Marcus Wolf

[permalink] [raw]
Subject: Re: [PATCH 2/2] Staging: pi433: check error after kthread_run()

Reviewed-by: Marcus Wolf <[email protected]>
Tested-by: Marcus Wolf <[email protected]>

Am So, 16.07.2017, 16:48 schrieb Joseph Wright:
> Error should be checked with IS_ERR after calling kthread_run()
> instead of comparing the returned pointer to an int.
>
> Found by sparse warning:
>
> incompatible types for operation (<)
> left side has type struct task_struct *tx_task_struct
> right side has type int
>
> Signed-off-by: Joseph Wright <[email protected]>
> ---
> drivers/staging/pi433/pi433_if.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
> index 46461b4..4f724a5 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -1152,7 +1152,7 @@ static int pi433_probe(struct spi_device *spi)
> device->tx_task_struct = kthread_run(pi433_tx_thread,
> device,
> "pi433_tx_task");
> - if (device->tx_task_struct < 0)
> + if (IS_ERR(device->tx_task_struct))
> {
> dev_dbg(device->dev, "start of send thread failed");
> goto send_thread_failed;
> --
> 2.9.3
>
>
>