You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Julian Foad <ju...@wandisco.com> on 2010/12/23 10:07:34 UTC

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

blair@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);
> 
> 


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

Posted by Blair Zajac <bl...@orcaware.com>.
On 12/23/10 2:07 AM, Julian Foad wrote:
> blair@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.)

Thanks, fixed in r1052448.  I went with the APR_SIZE_T_FMT approach instead of a 
cast.

Blair