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

Re: svn commit: r1052151 - /subversion/trunk/tools/server-side/svn-populate-node-origins-index.c

From: Julian Foad <julian.foad_at_wandisco.com>
Date: Thu, 23 Dec 2010 10:07:34 +0000

blair_at_apache.org wrote:
> URL: http://svn.apache.org/viewvc?rev=1052151&view=rev
> Log:
> Remove a gcc "implicit conversion shortens 64-bit value into a 32-bit
> value" warning.

tools/server-side/svn-populate-node-origins-index.c:140: warning: format
‘%ld’ expects type ‘long int’, but argument 3 has type ‘size_t’
tools/server-side/svn-populate-node-origins-index.c:140: warning: format
‘%ld’ expects type ‘long int’, but argument 4 has type ‘size_t’

The relationship between size_t and int varies among platforms. I think
you should cast (impicitly or explicitly) to "int", as there doesn't
seem to be a standard way to print it in C'89. (APR provides apr_size_t
and APR_SIZE_T_FMT, however; not sure if that's any use to you here.)

> Also, use %ld for printing svn_revnum_t values.

That part's correct.

- Julian

> * tools/server-side/svn-populate-node-origins-index.c
> (build_index):
> Store the result of strlen() in a size_t instead of an int.
> Store a revision in a svn_revnum_t instead of an int.
> Use %ld for constructing a printf format string and in the format
> string itself.
>
> Modified:
> subversion/trunk/tools/server-side/svn-populate-node-origins-index.c
>
> Modified: subversion/trunk/tools/server-side/svn-populate-node-origins-index.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/tools/server-side/svn-populate-node-origins-index.c?rev=1052151&r1=1052150&r2=1052151&view=diff
> ==============================================================================
> --- subversion/trunk/tools/server-side/svn-populate-node-origins-index.c (original)
> +++ subversion/trunk/tools/server-side/svn-populate-node-origins-index.c Thu Dec 23 02:50:08 2010
> @@ -120,8 +120,8 @@ build_index(const char *repos_path, apr_
> {
> svn_repos_t *repos;
> svn_fs_t *fs;
> - svn_revnum_t youngest_rev;
> - int i, slotsize;
> + svn_revnum_t youngest_rev, i;
> + size_t slotsize;
> const char *progress_fmt;
> apr_pool_t *subpool;
>
> @@ -134,9 +134,10 @@ build_index(const char *repos_path, apr_
> /* Fetch the youngest revision of the repository. */
> SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool));
> slotsize = strlen(apr_ltoa(pool, youngest_rev));
> - progress_fmt = apr_psprintf(pool,
> - "[%%%dd/%%%dd] Found %%d new lines of history."
> - "\n", slotsize, slotsize);
> + progress_fmt = apr_psprintf
> + (pool,
> + "[%%%ldld/%%%ldld] Found %%d new lines of history."
> + "\n", slotsize, slotsize);
>
> /* Now, iterate over all the revisions, calling index_revision_adds(). */
> subpool = svn_pool_create(pool);
>
>
Received on 2010-12-23 11:08:18 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.