Skip to contentSkip to conversation

Staging: pi433: fix sparse warnings

PATCH In review Joseph Wright 2 participants 6 messages Jul 19, 2017 – Jul 20, 2017 Staging

lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.9.3
#1 lore raw

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?

---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/pi433/pi433_if.c +2 -2
index 1bc478a..46461b4 100644
@@ -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;
Signature · 1 line
2.9.3
Reviewed-by Marcus Wolf on v1 1/2
#2 lore raw

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

Am So, 16.07.2017, 16:48 schrieb Joseph Wright:

Quoted 37 lines

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?

---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/pi433/pi433_if.c +2 -3
index 1bc478a..46461b4 100644
@@ -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

#3 lore raw

PATCH 2/2 Staging: pi433: check error after kthread_run()

In reply to 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

---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/pi433_if.c +1 -1
index 46461b4..4f724a5 100644
@@ -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;
Signature · 1 line
2.9.3
#4 lore raw

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

Quoted 36 lines

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

---
drivers/staging/pi433/pi433_if.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/pi433_if.c +1 -2
index 46461b4..4f724a5 100644
@@ -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

Reviewed-by Marcus Wolf Tested-by Marcus Wolf on v1 2/2
#5 lore raw

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

In reply to Joseph Wright

Am So, 16.07.2017, 16:48 schrieb Joseph Wright:

Quoted 32 lines

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

---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/pi433_if.c +1 -2
index 46461b4..4f724a5 100644
@@ -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