Login | Register
My pages Projects Community openCollabNet

Discussions > dev [DISABLED] > checksum / compare_files question

subversion
Discussion topic

Back to topic list

checksum / compare_files question

Author neels
Full name Neels Janosch Hofmeyr
Date 2009-05-18 18:09:28 PDT
Message Hi all,

I came across this snippet of code:

subversion/libsvn_su​br/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
Attachments

« Previous message in topic | 1 of 7 | Next message in topic »

Messages

Show all messages in topic

checksum / compare_files question neels Neels Janosch Hofmeyr 2009-05-18 18:09:28 PDT
     Re: checksum / compare_files question crazycat Edmund Wong 2009-05-18 20:50:37 PDT
     Re: checksum / compare_files question jszakmeister John Szakmeister 2009-05-19 00:25:31 PDT
         Re: checksum / compare_files question stsp Stefan Sperling 2009-05-19 03:53:52 PDT
             Re: checksum / compare_files question jszakmeister John Szakmeister 2009-05-19 04:09:45 PDT
                 Re: checksum / compare_files question neels Neels Janosch Hofmeyr 2009-05-19 14:06:30 PDT
                     Re: checksum / compare_files question jszakmeister John Szakmeister 2009-05-20 00:08:44 PDT
Messages per page: