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

RE: svn commit: r33975 - in trunk/subversion: libsvn_fs libsvn_fs_base libsvn_fs_base/bdb libsvn_fs_base/notes libsvn_fs_base/util libsvn_fs_fs tests/libsvn_fs_base

From: Bert Huijben <bert_at_vmoo.com>
Date: Sun, 16 Nov 2008 13:47:28 +0100

> -----Original Message-----
> From: cmpilato_at_tigris.org [mailto:cmpilato_at_tigris.org]
> Sent: Friday, October 31, 2008 4:10 PM
> To: svn_at_subversion.tigris.org
> Subject: svn commit: r33975 - in trunk/subversion: libsvn_fs
> libsvn_fs_base libsvn_fs_base/bdb libsvn_fs_base/notes
> libsvn_fs_base/util libsvn_fs_fs tests/libsvn_fs_base
>
> Author: cmpilato
> Date: Fri Oct 31 08:10:08 2008
> New Revision: 33975
>
> Log:
> Teach the Berkeley DB backend to store both MD5 and SHA1 checksums --
> as
> available and allowed for the FS format -- in the `representations'
> table.
>

...

> * subversion/libsvn_fs_base/reps-strings.c
> (svn_fs_base__rep_contents_checksums): Was
> svn_fs_base__rep_contents_checksum(). Rename 'checksum' parameter
> to 'md5_checksum', and add 'sha1_checksum' parameter.
> (make_fulltext_rep): Rename 'checksum' parameter to 'md5_checksum',
> and add 'sha1_checksum' parameter, duping both.
> (svn_fs_base__get_mutable_rep): Update call to make_fulltext_rep.
> (txn_body_read_rep): Compare both MD5 and SHA1 checksums against
> their stored values where possible.
> (svn_fs_base__rep_contents): Allow checksum tests of either type of
> checksum, but prefer a SHA1 comparison.
> (struct rep_write_baton): Rename 'checksum_ctx' and 'checksum' to
> 'md5_checksum_ctx' and 'md5_checksum', respective; add
> 'sha1_checksum_ctx' and 'sha1_checksum'.
> (rep_write_get_baton): Track renamed baton members, and also
> initialize an MD5 checksum context.
> (txn_body_write_rep): Update both checksum contexts.
> (txn_body_write_close_rep): Copy both checksum contexts into the
> representation.
> (rep_write_close_contents): Finalize both checksum contexts.
> (rep_contents_clear): Clear both representation checksums.

...

> Modified: trunk/subversion/libsvn_fs_base/reps-strings.c
> URL:
> http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_fs_base/reps-
> strings.c?pathrev=33975&r1=33974&r2=33975
> =======================================================================
> =======
> --- trunk/subversion/libsvn_fs_base/reps-strings.c Fri Oct 31
> 03:46:56 2008 (r33974)
> +++ trunk/subversion/libsvn_fs_base/reps-strings.c Fri Oct 31
> 08:10:08 2008 (r33975)
> @@ -62,14 +62,19 @@ static svn_boolean_t rep_is_mutable(repr
> *
> * If STR_KEY is non-null, copy it into an allocation from POOL.
> *
> - * If CHECKSUM is non-null, use it as the checksum for the new rep;
> - * else initialize the rep with an all-zero (i.e., always successful)
> - * checksum.
> + * If MD5_CHECKSUM is non-null, use it as the MD5 checksum for the new
> + * rep; else initialize the rep with an all-zero (i.e., always
> + * successful) MD5 checksum.
> + *
> + * If SHA1_CHECKSUM is non-null, use it as the SHA1 checksum for the
> new
> + * rep; else initialize the rep with an all-zero (i.e., always
> + * successful) SHA1 checksum.
> */
> static representation_t *
> make_fulltext_rep(const char *str_key,
> const char *txn_id,
> - svn_checksum_t *checksum,
> + svn_checksum_t *md5_checksum,
> + svn_checksum_t *sha1_checksum,
> apr_pool_t *pool)
>
> {
> @@ -77,9 +82,8 @@ make_fulltext_rep(const char *str_key,
> if (txn_id && *txn_id)
> rep->txn_id = apr_pstrdup(pool, txn_id);
> rep->kind = rep_kind_fulltext;
> -
> - rep->checksum = svn_checksum_dup(checksum, pool);
> -
> + rep->md5_checksum = svn_checksum_dup(md5_checksum, pool);
> + rep->sha1_checksum = svn_checksum_dup(sha1_checksum, pool);
> rep->contents.fulltext.string_key
> = str_key ? apr_pstrdup(pool, str_key) : NULL;
> return rep;
> @@ -566,6 +570,8 @@ svn_fs_base__get_mutable_rep(const char
> representation and return its key to the caller. */
> SVN_ERR(svn_fs_bdb__string_append(fs, &new_str, 0, NULL, trail,
> pool));
> rep = make_fulltext_rep(new_str, txn_id,
> +
> svn_checksum_empty_checksum(svn_checksum_md5,
> + pool),
>
> svn_checksum_empty_checksum(svn_checksum_sha1,
> pool),
> pool);
> @@ -748,16 +754,20 @@ svn_fs_base__rep_contents_size(svn_files
>
>
> svn_error_t *
> -svn_fs_base__rep_contents_checksum(svn_checksum_t **checksum,
> - svn_fs_t *fs,
> - const char *rep_key,
> - trail_t *trail,
> - apr_pool_t *pool)
> +svn_fs_base__rep_contents_checksums(svn_checksum_t **md5_checksum,
> + svn_checksum_t **sha1_checksum,
> + svn_fs_t *fs,
> + const char *rep_key,
> + trail_t *trail,
> + apr_pool_t *pool)
> {
> representation_t *rep;
>
> SVN_ERR(svn_fs_bdb__read_rep(&rep, fs, rep_key, trail, pool));
> - *checksum = svn_checksum_dup(rep->checksum, pool);
> + if (md5_checksum)
> + *md5_checksum = svn_checksum_dup(rep->md5_checksum, pool);
> + if (sha1_checksum)
> + *sha1_checksum = svn_checksum_dup(rep->sha1_checksum, pool);
>
> return SVN_NO_ERROR;
> }
> @@ -802,19 +812,20 @@ svn_fs_base__rep_contents(svn_string_t *
> /* Just the standard paranoia. */
> {
> representation_t *rep;
> - svn_checksum_t *checksum;
> + svn_checksum_t *checksum, *rep_checksum;
>
> SVN_ERR(svn_fs_bdb__read_rep(&rep, fs, rep_key, trail, pool));
> - SVN_ERR(svn_checksum(&checksum, rep->checksum->kind, str->data,
> str->len,
> + rep_checksum = rep->sha1_checksum ? rep->sha1_checksum : rep-
> >md5_checksum;
> + SVN_ERR(svn_checksum(&checksum, rep_checksum->kind, str->data,
> str->len,
> pool));
>
> - if (! svn_checksum_match(checksum, rep->checksum))
> + if (! svn_checksum_match(checksum, rep_checksum))
> return svn_error_createf
> (SVN_ERR_FS_CORRUPT, NULL,
> _("Checksum mismatch on rep '%s':\n"
> " expected: %s\n"
> " actual: %s\n"), rep_key,
> - svn_checksum_to_cstring_display(rep->checksum, pool),
> + svn_checksum_to_cstring_display(rep_checksum, pool),
> svn_checksum_to_cstring_display(checksum, pool));
> }
>
> @@ -900,19 +911,30 @@ txn_body_read_rep(void *baton, trail_t *
> SVN_ERR(svn_fs_bdb__read_rep(&rep, args->rb->fs,
> args->rb->rep_key,
> trail, trail->pool));
> +
> + if (rep->md5_checksum
> + && (! svn_checksum_match(rep->md5_checksum,
> + args->rb->md5_checksum)))
> + return svn_error_createf
> + (SVN_ERR_FS_CORRUPT, NULL,
> + _("MD5 checksum mismatch on rep '%s':\n"
> + " expected: %s\n"
> + " actual: %s\n"), args->rb->rep_key,
> + svn_checksum_to_cstring_display(rep->md5_checksum,
> + trail->pool),
> + svn_checksum_to_cstring_display(checked_checksum,
> + trail->pool));
>
> - if (rep->checksum->kind == svn_checksum_md5)
> - checked_checksum = args->rb->md5_checksum;
> - else if (rep->checksum->kind == svn_checksum_sha1)
> - checked_checksum = args->rb->sha1_checksum;
> -
> - if (! svn_checksum_match(checked_checksum, rep-
> >checksum))
> + if (rep->sha1_checksum
> + && (! svn_checksum_match(rep->sha1_checksum,
> + args->rb->sha1_checksum)))
> return svn_error_createf
> (SVN_ERR_FS_CORRUPT, NULL,
> - _("Checksum mismatch on rep '%s':\n"
> + _("SHA1 checksum mismatch on rep '%s':\n"
> " expected: %s\n"
> " actual: %s\n"), args->rb->rep_key,
> - svn_checksum_to_cstring_display(rep->checksum,
> trail->pool),
> + svn_checksum_to_cstring_display(rep->sha1_checksum,
> + trail->pool),
> svn_checksum_to_cstring_display(checked_checksum,
> trail->pool));
> }

This last line gives
f:\svn-2008\dev\subversion\libsvn_fs_base\reps-strings.c(926) : warning C4700: uninitialized local variable 'checked_checksum' used

(See also the buildbot output)

This patch removes all possible initializations of checked_checksum, but
starts using it in this error message.

        Bert

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-11-16 13:47:53 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.