Thread (10 messages) 10 messages, 4 authors, 2012-04-29

Re: [PATCH 1/2] Fix sign extension of bitmap_offset in super1.c

From: Doug Ledford <hidden>
Date: 2012-04-26 15:35:51

On 04/26/2012 11:32 AM, Richard Henderson wrote:
On 04/26/12 08:25, Jes Sorensen wrote:
quoted
Just checking mdadm.h and bswap32() is defined like this:

#define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
                     ((x) & 0xff000000U) >> 24 | \
                     ((x) & 0x0000ff00U) << 8  | \
                     ((x) & 0x00ff0000U) >> 8)

so I am not 100% sure just swapping to an s32 in the struct will work on
big endian systems? Will the 0x000000ffU not force the conversion back
to unsigned or what happens in this case?
This is actually semi-complicated.  c89 or c99 rules?  X already of a
type larger than unsigned int?

But if X is signed int, this entire expression will always be unsigned.

You're certainly better off with a cast as we discussed on irc.
Answering this question is beyond my bitfield/bigendian/littleendian
foo.  So nice to have Richard around ;-)


-- 
Doug Ledford [off-list ref]
              GPG KeyID: 0E572FDD
	      http://people.redhat.com/dledford

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help