List Info

Thread: bswap16(v); in bus_space.c




bswap16(v); in bus_space.c
user name
2006-09-14 18:14:07
Hi,

In netbsd-4, in mac68k/mac68k/bus_space.c, bswap16(v); on
line 418, I'm 
guessing, gets reduced to nothing, and gcc complains:

         v = mac68k_bsrs2_gen(t, h, offset);
         if (h->swapped) {
                 bswap16(v);
         }


../../../../arch/mac68k/mac68k/bus_space.c: In function
'mac68k_bsr2_gen':
../../../../arch/mac68k/mac68k/bus_space.c:418: warning:
statement with no effect
*** Error code 1

Since this code isn't ever going to run on anything but
mac68k which, of 
course, is big endian, is there any reason why this is in
there?

John Klos
-- 
Today is the day that my destiny calls me!
   Meowth
bswap16(v); in bus_space.c
user name
2006-09-14 18:14:07
Hi,

In netbsd-4, in mac68k/mac68k/bus_space.c, bswap16(v); on
line 418, I'm 
guessing, gets reduced to nothing, and gcc complains:

         v = mac68k_bsrs2_gen(t, h, offset);
         if (h->swapped) {
                 bswap16(v);
         }


../../../../arch/mac68k/mac68k/bus_space.c: In function
'mac68k_bsr2_gen':
../../../../arch/mac68k/mac68k/bus_space.c:418: warning:
statement with no effect
*** Error code 1

Since this code isn't ever going to run on anything but
mac68k which, of 
course, is big endian, is there any reason why this is in
there?

John Klos
-- 
Today is the day that my destiny calls me!
   Meowth
bswap16(v); in bus_space.c
user name
2006-09-14 18:15:43
> In netbsd-4, in mac68k/mac68k/bus_space.c, bswap16(v);
on line 418, I'm 
> guessing, gets reduced to nothing, and gcc complains:
>
>        v = mac68k_bsrs2_gen(t, h, offset);
>        if (h->swapped) {
>                bswap16(v);
>        }

I forgot to mention that I'm using gcc 4 to build a kernel
natively on 
netbsd-4 on mac68k.

John
bswap16(v); in bus_space.c
user name
2006-09-14 18:15:43
> In netbsd-4, in mac68k/mac68k/bus_space.c, bswap16(v);
on line 418, I'm 
> guessing, gets reduced to nothing, and gcc complains:
>
>        v = mac68k_bsrs2_gen(t, h, offset);
>        if (h->swapped) {
>                bswap16(v);
>        }

I forgot to mention that I'm using gcc 4 to build a kernel
natively on 
netbsd-4 on mac68k.

John
bswap16(v); in bus_space.c
user name
2006-09-14 21:59:43
On Thu, Sep 14, 2006 at 11:14:07AM -0700, John Klos wrote:
> Hi,
> 
> In netbsd-4, in mac68k/mac68k/bus_space.c, bswap16(v);
on line 418, I'm 
> guessing, gets reduced to nothing, and gcc complains:
> 
>         v = mac68k_bsrs2_gen(t, h, offset);
>         if (h->swapped) {
>                 bswap16(v);
>         }
> 
> 
> ../../../../arch/mac68k/mac68k/bus_space.c: In function
'mac68k_bsr2_gen':
> ../../../../arch/mac68k/mac68k/bus_space.c:418:
warning: statement with no 
> effect
> *** Error code 1

bswap16() unconditionally swaps the upper and lower bytes of
a 16-bit
value--it doesn't get reduced to nothing, unlike htons(),
which is a
no-op on big-endian systems. What gcc is complaining about
is that the
return value from bswap16() isn't assigned to anything.

It looks like what's intended is:

Index: bus_space.c
============================================================
=======
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/bus_space.c,v
retrieving revision 1.28
diff -u -r1.28 bus_space.c
--- bus_space.c	24 Dec 2005 20:07:15 -0000	1.28
+++ bus_space.c	14 Sep 2006 21:59:09 -0000
 -415,7
+415,7 
 
 	v = mac68k_bsrs2_gen(t, h, offset);
 	if (h->swapped) {
-		bswap16(v);
+		v = bswap16(v);
 	}
 	return v;
 }

-- 
Name: Dave Huang         |  Mammal, mammal / their names are
called /
INet: khymazeotrope.org |  they raise a paw / the bat, the cat
/
FurryMUCK: Dahan         |  dolphin and dog / koala bear and
hog -- TMBG
Dahan: Hani G Y+C 30 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F-
Q+++ P+ B+ PA+ PL++
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )