linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: tty: serial: Add 8250-core based omap driver
@ 2014-11-12  8:48 Dan Carpenter
  2014-11-12  9:28 ` [PATCH 1/2] tty: serial: 8250: omap: line is unsigned, don't check < 0 Sebastian Andrzej Siewior
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-11-12  8:48 UTC (permalink / raw)
  To: bigeasy; +Cc: linux-serial

Hello Sebastian Andrzej Siewior,

The patch 61929cf0169d: "tty: serial: Add 8250-core based omap
driver" from Sep 29, 2014, leads to the following static checker
warning:

	drivers/tty/serial/8250/8250_omap.c:1025 omap8250_probe()
	warn: unsigned 'up.port.line' is never less than zero.

drivers/tty/serial/8250/8250_omap.c
  1015  
  1016          if (pdev->dev.of_node) {
  1017                  up.port.line = of_alias_get_id(pdev->dev.of_node, "serial");
  1018                  of_property_read_u32(pdev->dev.of_node, "clock-frequency",
  1019                                       &up.port.uartclk);
  1020                  priv->wakeirq = irq_of_parse_and_map(pdev->dev.of_node, 1);
  1021          } else {
  1022                  up.port.line = pdev->id;
  1023          }
  1024  
  1025          if (up.port.line < 0) {
                    ^^^^^^^^^^^^^^^^
Impossible.

  1026                  dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
  1027                          up.port.line);
  1028                  return -ENODEV;
                        ^^^^^^^^^^^^^^
It's better to preserve the error code normally.

  1029          }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] tty: serial: 8250: omap: line is unsigned, don't check < 0
  2014-11-12  8:48 tty: serial: Add 8250-core based omap driver Dan Carpenter
@ 2014-11-12  9:28 ` Sebastian Andrzej Siewior
  2014-11-12  9:28   ` [PATCH 2/2] tty: serial: omap_serial: " Sebastian Andrzej Siewior
  2014-11-25 18:08   ` [PATCH 1/2] tty: serial: 8250: omap: " Sebastian Andrzej Siewior
  0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-11-12  9:28 UTC (permalink / raw)
  To: linux-serial; +Cc: dan.carpenter, Greg Kroah-Hartman, Sebastian Andrzej Siewior

Dan Carpenter reported:
|drivers/tty/serial/8250/8250_omap.c:1025 omap8250_probe()
|warn: unsigned 'up.port.line' is never less than zero.
|1025          if (up.port.line < 0) {

I (wrongly) assumed that line is an int and compiler didn't complain nor
did sparse. Since of_alias_get_id() and pdev->id can get negative I
check for the error via ret variable.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/tty/serial/8250/8250_omap.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 1681875f2996..907100eb8030 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1014,19 +1014,20 @@ static int omap8250_probe(struct platform_device *pdev)
 	up.port.unthrottle = omap_8250_unthrottle;
 
 	if (pdev->dev.of_node) {
-		up.port.line = of_alias_get_id(pdev->dev.of_node, "serial");
+		ret = of_alias_get_id(pdev->dev.of_node, "serial");
+
 		of_property_read_u32(pdev->dev.of_node, "clock-frequency",
 				     &up.port.uartclk);
 		priv->wakeirq = irq_of_parse_and_map(pdev->dev.of_node, 1);
 	} else {
-		up.port.line = pdev->id;
+		ret = pdev->id;
 	}
-
-	if (up.port.line < 0) {
-		dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
-			up.port.line);
-		return -ENODEV;
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to get alias/pdev id\n");
+		return ret;
 	}
+	up.port.line = ret;
+
 	if (!up.port.uartclk) {
 		up.port.uartclk = DEFAULT_CLK_SPEED;
 		dev_warn(&pdev->dev,
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] tty: serial: omap_serial: line is unsigned, don't check < 0
  2014-11-12  9:28 ` [PATCH 1/2] tty: serial: 8250: omap: line is unsigned, don't check < 0 Sebastian Andrzej Siewior
@ 2014-11-12  9:28   ` Sebastian Andrzej Siewior
  2014-11-25 18:08   ` [PATCH 1/2] tty: serial: 8250: omap: " Sebastian Andrzej Siewior
  1 sibling, 0 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-11-12  9:28 UTC (permalink / raw)
  To: linux-serial; +Cc: dan.carpenter, Greg Kroah-Hartman, Sebastian Andrzej Siewior

Dan Carpenter reported:
|drivers/tty/serial/8250/8250_omap.c:1025 omap8250_probe()
|warn: unsigned 'up.port.line' is never less than zero.
|1025          if (up.port.line < 0) {

Since of_alias_get_id() and pdev->id can get negative I check for the
error via ret variable.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/tty/serial/omap-serial.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6cda5cd8b513..9401d2f9c119 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1682,16 +1682,16 @@ static int serial_omap_probe(struct platform_device *pdev)
 	up->port.ops = &serial_omap_pops;
 
 	if (pdev->dev.of_node)
-		up->port.line = of_alias_get_id(pdev->dev.of_node, "serial");
+		ret = of_alias_get_id(pdev->dev.of_node, "serial");
 	else
-		up->port.line = pdev->id;
+		ret = pdev->id;
 
-	if (up->port.line < 0) {
+	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
-								up->port.line);
-		ret = -ENODEV;
+			ret);
 		goto err_port_line;
 	}
+	up->port.line = ret;
 
 	ret = serial_omap_probe_rs485(up, pdev->dev.of_node);
 	if (ret < 0)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] tty: serial: 8250: omap: line is unsigned, don't check < 0
  2014-11-12  9:28 ` [PATCH 1/2] tty: serial: 8250: omap: line is unsigned, don't check < 0 Sebastian Andrzej Siewior
  2014-11-12  9:28   ` [PATCH 2/2] tty: serial: omap_serial: " Sebastian Andrzej Siewior
@ 2014-11-25 18:08   ` Sebastian Andrzej Siewior
  2014-11-25 19:27     ` Greg Kroah-Hartman
  1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-11-25 18:08 UTC (permalink / raw)
  To: linux-serial; +Cc: dan.carpenter, Greg Kroah-Hartman

On 11/12/2014 10:28 AM, Sebastian Andrzej Siewior wrote:
> Dan Carpenter reported:
> |drivers/tty/serial/8250/8250_omap.c:1025 omap8250_probe()
> |warn: unsigned 'up.port.line' is never less than zero.
> |1025          if (up.port.line < 0) {
> 
> I (wrongly) assumed that line is an int and compiler didn't complain nor
> did sparse. Since of_alias_get_id() and pdev->id can get negative I
> check for the error via ret variable.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Greg, did those two slip through or do you wait for something until you
apply them?

Sebastian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] tty: serial: 8250: omap: line is unsigned, don't check < 0
  2014-11-25 18:08   ` [PATCH 1/2] tty: serial: 8250: omap: " Sebastian Andrzej Siewior
@ 2014-11-25 19:27     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2014-11-25 19:27 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-serial, dan.carpenter

On Tue, Nov 25, 2014 at 07:08:02PM +0100, Sebastian Andrzej Siewior wrote:
> On 11/12/2014 10:28 AM, Sebastian Andrzej Siewior wrote:
> > Dan Carpenter reported:
> > |drivers/tty/serial/8250/8250_omap.c:1025 omap8250_probe()
> > |warn: unsigned 'up.port.line' is never less than zero.
> > |1025          if (up.port.line < 0) {
> > 
> > I (wrongly) assumed that line is an int and compiler didn't complain nor
> > did sparse. Since of_alias_get_id() and pdev->id can get negative I
> > check for the error via ret variable.
> > 
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> 
> Greg, did those two slip through or do you wait for something until you
> apply them?

I'm still working on catching up with my tty/serial patches, this is in
the queue...

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-25 19:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12  8:48 tty: serial: Add 8250-core based omap driver Dan Carpenter
2014-11-12  9:28 ` [PATCH 1/2] tty: serial: 8250: omap: line is unsigned, don't check < 0 Sebastian Andrzej Siewior
2014-11-12  9:28   ` [PATCH 2/2] tty: serial: omap_serial: " Sebastian Andrzej Siewior
2014-11-25 18:08   ` [PATCH 1/2] tty: serial: 8250: omap: " Sebastian Andrzej Siewior
2014-11-25 19:27     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).