bug-gnulib
[Top][All Lists]
Advanced

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

Re: md5 cleanup


From: Paul Eggert
Subject: Re: md5 cleanup
Date: Sun, 23 Oct 2005 22:34:18 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> -  *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
> -  *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
> -                                                     (ctx->total[0] >> 29));
> +  ctx->buffer[(bytes + pad) / 4] = SWAP (ctx->total[0] << 3);
> +  ctx->buffer[(bytes + pad) / 4 + 1] = SWAP ((ctx->total[1] << 3) |
> +                                          (ctx->total[0] >> 29));

This sort of thing generates worse code than the original, no?  The
compiler isn't smart enough to know that bytes + pad is a multiple of
4.  Shouldn't the code look something like this instead?

  uint32_t *p = (uint32_t *) ((char *) ctx->buffer + bytes + pad);
  p[0] = SWAP (ctx->total[0] << 3);
  p[1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));

Also, in some other places I noticed some "char*"s.  GNU style is to
put a space between the type and the trailing "*" for pointer types,
e.g., "char *" rather than "char*".




reply via email to

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