Subject: Re: bswap16(v); in bus_space.c
To: John Klos <john@ziaspace.com>
From: None <khym@azeotrope.org>
List: port-mac68k
Date: 09/14/2006 16: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: khym@azeotrope.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++