From: Jes Sorensen <Jes.Sorensen@redhat.com>
To: Richard Henderson <rth@twiddle.net>
Cc: Doug Ledford <dledford@redhat.com>,
neilb@suse.de, joe.lawrence@stratus.com,
linux-raid@vger.kernel.org
Subject: Re: [PATCH 1/2] Fix sign extension of bitmap_offset in super1.c
Date: Thu, 26 Apr 2012 17:36:10 +0200 [thread overview]
Message-ID: <4F996B6A.4070705@redhat.com> (raw)
In-Reply-To: <4F996A94.3060509@twiddle.net>
On 04/26/12 17:32, Richard Henderson wrote:
> On 04/26/12 08:25, Jes Sorensen wrote:
>> 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?
This is what I was afraid of :)
> 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.
In this particular case X would be a signed int, so we would end up with
unsigned and still need the cast.
I will opt for the cast in this case - thanks a lot for the clarification.
Cheers,
Jes
next prev parent reply other threads:[~2012-04-26 15:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 15:12 [PATCH 0/2] Solve problem adding internal bitmaps to 1.0 arrays Jes.Sorensen
2012-04-26 15:12 ` [PATCH 1/2] Fix sign extension of bitmap_offset in super1.c Jes.Sorensen
2012-04-26 15:18 ` Doug Ledford
2012-04-26 15:21 ` Jes Sorensen
2012-04-26 15:25 ` Jes Sorensen
2012-04-26 15:32 ` Richard Henderson
2012-04-26 15:35 ` Doug Ledford
2012-04-26 15:36 ` Jes Sorensen [this message]
2012-04-29 23:55 ` NeilBrown
2012-04-26 15:12 ` [PATCH 2/2] Introduce sysfs_set_num_signed() and use it to set bitmap/offset Jes.Sorensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F996B6A.4070705@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=dledford@redhat.com \
--cc=joe.lawrence@stratus.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).