[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] for some of issue #649

From: Benjamin Pflugmann <benjamin-svn-dev_at_pflugmann.de>
Date: 2003-01-07 07:13:42 CET

On Mon 2003-01-06 at 15:51:29 -0600, Karl Fogel wrote:
[...]
> +/* Compare digests D1 and D2, each MD5_DIGESTSIZE bytes long. If
> + * neither is all zeros, and they do not match, then return false.
> + * Else return true.
> + */
> +static svn_boolean_t
> +checksums_match (unsigned const char d1[], unsigned const char d2[])
> +{
> + auto unsigned char zeros[MD5_DIGESTSIZE] = { 0 };
> +
> + if ((strncmp (d1, zeros, MD5_DIGESTSIZE) == 0)
> + || (strncmp (d2, zeros, MD5_DIGESTSIZE) == 0))
> + return TRUE;
> + else
> + return (strncmp (d1, d2, MD5_DIGESTSIZE) == 0);
> +}

Aside from what already had pointed out, just a minor issue: I
consider returning TRUE in an if-statement bad style (it is
redundant). How about something like

  return ((strncmp (d1, zeros, MD5_DIGESTSIZE) == 0)
          || (strncmp (d2, zeros, MD5_DIGESTSIZE) == 0)
          || (strncmp (d1, d2, MD5_DIGESTSIZE) == 0));

HTH,

        Benjamin.

  • application/pgp-signature attachment: stored
Received on Tue Jan 7 07:14:37 2003

This is an archived mail posted to the Subversion Dev mailing list.