bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc bug causes parted to write bad GPT entries


From: Andreas Dilger
Subject: Re: gcc bug causes parted to write bad GPT entries
Date: Fri, 15 Mar 2002 16:04:54 -0700
User-agent: Mutt/1.3.27i

On Mar 15, 2002  22:15 +0000, Richard Hirst wrote:
> David Mosberger wrote:
> > However, I also feel strongly the defining the efi_guid_t like this:
> > 
> > typedef struct {
> >         uint32_t time_low;
> >         uint16_t time_mid;
> >         uint16_t time_hi_and_version;
> >         uint8_t  clock_seq_hi_and_reserved;
> >         uint8_t  clock_seq_low;
> >         uint8_t  node[6];
> > } __attribute__ ((packed)) efi_guid_t;
> > 
> > is fundamentally broken, because it introduces byte-order dependency.
> > I'd recommend doing something along the following lines instead:
> > 
> > typedef unsigned char guid_t[16];
> > #define EFI_GUID(a,b,c,b0,b1,b2,b3,b4,b5,b6,b7)                             
> >  \
> > { (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
> >   (b) & 0xff, ((b) >> 8) & 0xff,                                     \
> >   (c) & 0xff, ((c) >> 8) & 0xff,                                     \
> >   (b0), (b1), (b2), (b3), (b4), (b5), (b6), (b7) }
> > 
> > This is untested, but I think you'll get the idea.  This should be
> > much better because it works independent of the host's byte-order and
> > doesn't require using gcc-only extensions to C.  It will also work
> > around the compiler bug until that gets fixed.

Please see the libuuid code to do the same.  It has "pack" and "unpack"
functions which handle this nicely.

Cheers, Andreas
--
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert




reply via email to

[Prev in Thread] Current Thread [Next in Thread]