This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] crypt: Fix strict aliasing warnings


On Monday, July 18, 2011 09:59:59 Marek Polacek wrote:
> +static void
> +le64_copy (char *dest, uint64_t x)
> +{
> +  for (size_t i = 0; i < 8; ++i)
> +    {
> +      dest[i] = (uint8_t) x;
> +      x >>= 8;
> +    }
> +}

isnt this just a memcpy() for LE systems ?

> +static void
> +be64_copy (char *dest, uint64_t x)
> +{
> +  for (size_t i = 8; i-- > 0; x >>= 8)
> +    dest[i] = (uint8_t) x;
> +}

and this is just  memcpy() for BE systems ?

> +static void
> +be64_copy (char *dest, uint64_t x)
> +{
> +  for (size_t i = 8; i-- > 0; x >>= 8)
> +    dest[i] = (uint8_t) x;
> +}

looks like this belongs in a local header file rather than copying & pasting 
the same thing over and over ...
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]