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

checksum / compare_files question

From: Neels Janosch Hofmeyr <neels_at_elego.de>
Date: Tue, 19 May 2009 04:16:13 +0200

Hi all,

I came across this snippet of code:

subversion/libsvn_subr/checksum.c:
[[[
svn_boolean_t
svn_checksum_match(const svn_checksum_t *checksum1,
                   const svn_checksum_t *checksum2)
{
  if (checksum1 == NULL || checksum2 == NULL)
    return TRUE;
]]]

I don't see how that makes sense. If it does, then the function name is
misleading. The comment from include/checksum.h is ... tricky:

[[[
/** Compare checksums @a checksum1 and @a checksum2. If their kinds do not
 * match or if neither is all zeros, and their content does not match, then
 * return FALSE; else return TRUE.
 *
 * @since New in 1.6.
 */
svn_boolean_t
svn_checksum_match(const svn_checksum_t *checksum1,
                   const svn_checksum_t *checksum2);
]]]

So, which way should I fix this. Like this:
[[[
  if (checksum1 == NULL || checksum2 == NULL)
    return (checksum1 == checksum2)? TRUE:FALSE;
]]]
[[[
/** Compare checksums @a checksum1 and @a checksum2. Return TRUE if both
 * their kinds and content match, FALSE otherwise.
]]]

Or like this:
[[[
/** Compare checksums @a checksum1 and @a checksum2. Return TRUE if both
 * their kinds and content match, FALSE otherwise. However, if one of the
 * checksums is NULL, return TRUE, even if the other one is non-NULL.
]]]

?

I am not really getting though what the reference "if neither is all zeros"
in the original comment is trying to say -- whether it's the NULLness of the
pointer or whether the checksum digits are all '0'.

Thanks,
~Neels

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2305880

Received on 2009-05-19 04:16:46 CEST

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