Netdev List
 help / color / mirror / Atom feed
* [patch 2/2] rocker: silence shift wrapping warning
@ 2015-02-25 13:36 Dan Carpenter
  2015-02-25 13:44 ` Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-02-25 13:36 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: Scott Feldman, netdev, linux-kernel, kernel-janitors

"val" is declared as a u64 so static checkers complain that this shift
can wrap.  I don't have the hardware but probably it's doesn't have over
31 ports.  Still we may as well silence the warning even if it's not a
real bug.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 713a13c..9fb6948 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -1257,9 +1257,9 @@ static void rocker_port_set_enable(struct rocker_port *rocker_port, bool enable)
 	u64 val = rocker_read64(rocker_port->rocker, PORT_PHYS_ENABLE);
 
 	if (enable)
-		val |= 1 << rocker_port->lport;
+		val |= 1ULL << rocker_port->lport;
 	else
-		val &= ~(1 << rocker_port->lport);
+		val &= ~(1ULL << rocker_port->lport);
 	rocker_write64(rocker_port->rocker, PORT_PHYS_ENABLE, val);
 }
 

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

* Re: [patch 2/2] rocker: silence shift wrapping warning
  2015-02-25 13:36 [patch 2/2] rocker: silence shift wrapping warning Dan Carpenter
@ 2015-02-25 13:44 ` Jiri Pirko
  2015-02-25 13:50 ` Scott Feldman
  2015-02-27 20:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2015-02-25 13:44 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Scott Feldman, netdev, linux-kernel, kernel-janitors

Wed, Feb 25, 2015 at 02:36:12PM CET, dan.carpenter@oracle.com wrote:
>"val" is declared as a u64 so static checkers complain that this shift
>can wrap.  I don't have the hardware but probably it's doesn't have over

It's a QEMU hardware, you can have it easily.

>31 ports.  Still we may as well silence the warning even if it's not a
>real bug.

It can have up to 62 ports.

>
>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>

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

* Re: [patch 2/2] rocker: silence shift wrapping warning
  2015-02-25 13:36 [patch 2/2] rocker: silence shift wrapping warning Dan Carpenter
  2015-02-25 13:44 ` Jiri Pirko
@ 2015-02-25 13:50 ` Scott Feldman
  2015-02-27 20:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Scott Feldman @ 2015-02-25 13:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jiri Pirko, Netdev, linux-kernel@vger.kernel.org, kernel-janitors

On Wed, Feb 25, 2015 at 5:36 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> "val" is declared as a u64 so static checkers complain that this shift
> can wrap.  I don't have the hardware but probably it's doesn't have over
> 31 ports.  Still we may as well silence the warning even if it's not a
> real bug.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
> index 713a13c..9fb6948 100644
> --- a/drivers/net/ethernet/rocker/rocker.c
> +++ b/drivers/net/ethernet/rocker/rocker.c
> @@ -1257,9 +1257,9 @@ static void rocker_port_set_enable(struct rocker_port *rocker_port, bool enable)
>         u64 val = rocker_read64(rocker_port->rocker, PORT_PHYS_ENABLE);
>
>         if (enable)
> -               val |= 1 << rocker_port->lport;
> +               val |= 1ULL << rocker_port->lport;
>         else
> -               val &= ~(1 << rocker_port->lport);
> +               val &= ~(1ULL << rocker_port->lport);
>         rocker_write64(rocker_port->rocker, PORT_PHYS_ENABLE, val);
>  }
>

Acked-by: Scott Feldman <sfeldma@gmail.com>

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

* Re: [patch 2/2] rocker: silence shift wrapping warning
  2015-02-25 13:36 [patch 2/2] rocker: silence shift wrapping warning Dan Carpenter
  2015-02-25 13:44 ` Jiri Pirko
  2015-02-25 13:50 ` Scott Feldman
@ 2015-02-27 20:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-02-27 20:59 UTC (permalink / raw)
  To: dan.carpenter; +Cc: jiri, sfeldma, netdev, linux-kernel, kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 25 Feb 2015 16:36:12 +0300

> "val" is declared as a u64 so static checkers complain that this shift
> can wrap.  I don't have the hardware but probably it's doesn't have over
> 31 ports.  Still we may as well silence the warning even if it's not a
> real bug.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
 
Applied.

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

end of thread, other threads:[~2015-02-27 20:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25 13:36 [patch 2/2] rocker: silence shift wrapping warning Dan Carpenter
2015-02-25 13:44 ` Jiri Pirko
2015-02-25 13:50 ` Scott Feldman
2015-02-27 20:59 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox