[Spice-devel] [spice-common PATCH 1/3] ppc: Fix lz magic endianess

Christophe Fergeau cfergeau at redhat.com
Mon Jun 29 05:33:25 PDT 2015


Hey,

On Mon, Jun 29, 2015 at 08:22:32AM -0400, Lukas Venhoda wrote:
> Hi.
> 
> I'm not sure if I follow, but I'll try to explain my reasoning as best I can.
> 
> What I meant by
> >magic will stay the same on both BE and LE machines
> was, that if we print the variable, we get the same result.

Thanks for the details, I think we are more or less meaning the same
thing. Imo "if we print the variable, we get the same result" is a bit
simplistic as the type of the value is very much important (uint8_t,
uint32_t and char[] variables will have different requirements to
achieve "printing the variable will give the same result"). If you can
write the log mentioning native endianness/LE/BE and ints, it will
probably get more accurate.

> I made this minimal example to test it on both LE and BE machine:
> 
> ---
> 
> #include <stdio.h>
> 
> #define QUIC_MAGIC_OLD (*(unsigned int *)"QUIC")
> #define QUIC_MAGIC_NEW 0x43495551
> 
> int main(void)
> {
>     printf("QUIC_MAGIC_OLD: %d\nQUIC_MAGIC_NEW: %d\n", QUIC_MAGIC_OLD, QUIC_MAGIC_NEW);
>     return 0;
> }

Just a small note, you could use %x rather than %d, this way it becomes
obvious whether 2 values would be the same after byteswapping.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150629/0338a023/attachment.sig>


More information about the Spice-devel mailing list