2015-02-25 13:36:31

by Dan Carpenter

[permalink] [raw]
Subject: [patch 2/2] rocker: silence shift wrapping warning

"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 <[email protected]>

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);
}


2015-02-25 13:44:12

by Jiri Pirko

[permalink] [raw]
Subject: Re: [patch 2/2] rocker: silence shift wrapping warning

Wed, Feb 25, 2015 at 02:36:12PM CET, [email protected] 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 <[email protected]>
Acked-by: Jiri Pirko <[email protected]>

2015-02-25 13:50:19

by Scott Feldman

[permalink] [raw]
Subject: Re: [patch 2/2] rocker: silence shift wrapping warning

On Wed, Feb 25, 2015 at 5:36 AM, Dan Carpenter <[email protected]> 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 <[email protected]>
>
> 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 <[email protected]>

2015-02-27 20:59:37

by David Miller

[permalink] [raw]
Subject: Re: [patch 2/2] rocker: silence shift wrapping warning

From: Dan Carpenter <[email protected]>
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 <[email protected]>

Applied.