* [PATCH] ambassador,firestream: "-1 >>" is implementation defined
@ 2006-11-13 20:22 Alexey Dobriyan
2006-11-13 20:26 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2006-11-13 20:22 UTC (permalink / raw)
To: Chas Williams; +Cc: netdev, Andrew Morton
6.5.7(5): The result of E1 >> E2 is E1 right-shifted E2 bit positions.
...
If E1 has a signed type and a negative value, the resulting value
is implementation defined.
So, cast -1 to unsigned type to make result well-defined.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/atm/ambassador.c | 2 +-
drivers/atm/firestream.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -972,7 +972,7 @@ static int make_rate (unsigned int rate,
}
case round_up: {
// check all bits that we are discarding
- if (man & (-1>>9)) {
+ if (man & ((unsigned int)-1>>9)) {
man = (man>>(32-9)) + 1;
if (man == (1<<9)) {
// no need to check for round up outside of range
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -512,7 +512,7 @@ static unsigned int make_rate (unsigned
}
case ROUND_UP: {
/* check all bits that we are discarding */
- if (man & (-1>>9)) {
+ if (man & ((unsigned int)-1>>9)) {
man = (man>>(32-9)) + 1;
if (man == (1<<9)) {
/* no need to check for round up outside of range */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ambassador,firestream: "-1 >>" is implementation defined
2006-11-13 20:22 [PATCH] ambassador,firestream: "-1 >>" is implementation defined Alexey Dobriyan
@ 2006-11-13 20:26 ` Al Viro
2006-11-14 0:12 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2006-11-13 20:26 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Chas Williams, netdev, Andrew Morton
On Mon, Nov 13, 2006 at 11:22:00PM +0300, Alexey Dobriyan wrote:
> 6.5.7(5): The result of E1 >> E2 is E1 right-shifted E2 bit positions.
> ...
> If E1 has a signed type and a negative value, the resulting value
> is implementation defined.
>
> So, cast -1 to unsigned type to make result well-defined.
Or just use ~0U and be done with that.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ambassador,firestream: "-1 >>" is implementation defined
2006-11-13 20:26 ` Al Viro
@ 2006-11-14 0:12 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2006-11-14 0:12 UTC (permalink / raw)
To: viro; +Cc: adobriyan, chas, netdev, akpm
From: Al Viro <viro@ftp.linux.org.uk>
Date: Mon, 13 Nov 2006 20:26:56 +0000
> On Mon, Nov 13, 2006 at 11:22:00PM +0300, Alexey Dobriyan wrote:
> > 6.5.7(5): The result of E1 >> E2 is E1 right-shifted E2 bit positions.
> > ...
> > If E1 has a signed type and a negative value, the resulting value
> > is implementation defined.
> >
> > So, cast -1 to unsigned type to make result well-defined.
>
> Or just use ~0U and be done with that.
I've modified the patch based upon Al's suggestion and applied
it to 2.6.20, thanks everyone.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-14 0:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-13 20:22 [PATCH] ambassador,firestream: "-1 >>" is implementation defined Alexey Dobriyan
2006-11-13 20:26 ` Al Viro
2006-11-14 0:12 ` David Miller
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).