You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Stein <gs...@gmail.com> on 2011/02/25 13:01:38 UTC

Re: svn commit: r1074461 - in /subversion/trunk: subversion/libsvn_subr/dirent_uri.c subversion/libsvn_wc/relocate.c tools/client-side/svnmucc/svnmucc.c

What?! ... what is this? I've never seen "missing sentinel". This just
seems to complicate the code for the sake of a compiler. And one that
historically has not been a problem for us.

??

On Fri, Feb 25, 2011 at 05:01,  <st...@apache.org> wrote:
> Author: stsp
> Date: Fri Feb 25 10:01:57 2011
> New Revision: 1074461
>
> URL: http://svn.apache.org/viewvc?rev=1074461&view=rev
> Log:
> Get rid of a few "missing sentinel" warnings from calls to apr_pstrcat()
> by explicitly casting NULL to the expected pointer type.
>
> * subversion/libsvn_subr/dirent_uri.c
>  (svn_fspath__canonicalize,
>   svn_fspath__get_longest_ancestor): Cast to (char *).
>
> * subversion/libsvn_wc/relocate.c
>  (svn_wc_relocate4): Same.
>
> * tools/client-side/svnmucc/svnmucc.c
>  (main): Same.
>
> Modified:
>    subversion/trunk/subversion/libsvn_subr/dirent_uri.c
>    subversion/trunk/subversion/libsvn_wc/relocate.c
>    subversion/trunk/tools/client-side/svnmucc/svnmucc.c
>
> Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=1074461&r1=1074460&r2=1074461&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
> +++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Fri Feb 25 10:01:57 2011
> @@ -2440,7 +2440,8 @@ svn_fspath__canonicalize(const char *fsp
>   if ((fspath[0] == '/') && (fspath[1] == '\0'))
>     return "/";
>
> -  return apr_pstrcat(pool, "/", svn_relpath_canonicalize(fspath, pool), NULL);
> +  return apr_pstrcat(pool, "/", svn_relpath_canonicalize(fspath, pool),
> +                     (char *)NULL);
>  }
>
>
> @@ -2571,7 +2572,7 @@ svn_fspath__get_longest_ancestor(const c
>                        svn_relpath_get_longest_ancestor(fspath1 + 1,
>                                                         fspath2 + 1,
>                                                         result_pool),
> -                       NULL);
> +                       (char *)NULL);
>
>   assert(svn_fspath__is_canonical(result));
>   return result;
>
> Modified: subversion/trunk/subversion/libsvn_wc/relocate.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/relocate.c?rev=1074461&r1=1074460&r2=1074461&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_wc/relocate.c (original)
> +++ subversion/trunk/subversion/libsvn_wc/relocate.c Fri Feb 25 10:01:57 2011
> @@ -146,7 +146,7 @@ svn_wc_relocate4(svn_wc_context_t *wc_ct
>   if (old_url_len == from_len)
>     new_url = to;
>   else
> -    new_url = apr_pstrcat(scratch_pool, to, old_url + from_len, NULL);
> +    new_url = apr_pstrcat(scratch_pool, to, old_url + from_len, (char *)NULL);
>   if (! svn_path_is_url(new_url))
>     return svn_error_createf(SVN_ERR_WC_INVALID_RELOCATION, NULL,
>                              _("Invalid relocation destination: '%s' "
>
> Modified: subversion/trunk/tools/client-side/svnmucc/svnmucc.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/tools/client-side/svnmucc/svnmucc.c?rev=1074461&r1=1074460&r2=1074461&view=diff
> ==============================================================================
> --- subversion/trunk/tools/client-side/svnmucc/svnmucc.c (original)
> +++ subversion/trunk/tools/client-side/svnmucc/svnmucc.c Fri Feb 25 10:01:57 2011
> @@ -1071,7 +1071,8 @@ main(int argc, const char **argv)
>                                                url), pool);
>               /* ### These relpaths are already URI-encoded. */
>               url = apr_pstrcat(pool, root_url, "/",
> -                                svn_relpath_canonicalize(url, pool), NULL);
> +                                svn_relpath_canonicalize(url, pool),
> +                                (char *)NULL);
>             }
>           url = sanitize_url(url, pool);
>           action->path[j] = url;
>
>
>

Re: svn commit: r1074461 - in /subversion/trunk: subversion/libsvn_subr/dirent_uri.c subversion/libsvn_wc/relocate.c tools/client-side/svnmucc/svnmucc.c

Posted by Stefan Sperling <st...@elego.de>.
On Fri, Feb 25, 2011 at 02:06:59PM +0200, Daniel Shahaf wrote:
> It was discussed a few months ago, conclusion was that the casts are
> necessary because they don't happen automatically for varargs functions
> (like apr_pstrcat()).
> 

Yes, see these, and other messages from the same thread,
for related discussion:
http://svn.haxx.se/dev/archive-2010-10/0053.shtml
http://svn.haxx.se/dev/archive-2010-10/0061.shtml
http://svn.haxx.se/dev/archive-2010-10/0071.shtml

> Greg Stein wrote on Fri, Feb 25, 2011 at 07:01:38 -0500:
> > What?! ... what is this? I've never seen "missing sentinel". This just
> > seems to complicate the code for the sake of a compiler. And one that
> > historically has not been a problem for us.

That's because NULL is defined differenly on different systems.
You don't see the warnings, but I do.

Re: svn commit: r1074461 - in /subversion/trunk: subversion/libsvn_subr/dirent_uri.c subversion/libsvn_wc/relocate.c tools/client-side/svnmucc/svnmucc.c

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
It was discussed a few months ago, conclusion was that the casts are
necessary because they don't happen automatically for varargs functions
(like apr_pstrcat()).

Greg Stein wrote on Fri, Feb 25, 2011 at 07:01:38 -0500:
> What?! ... what is this? I've never seen "missing sentinel". This just
> seems to complicate the code for the sake of a compiler. And one that
> historically has not been a problem for us.
> 
> ??
> 
> On Fri, Feb 25, 2011 at 05:01,  <st...@apache.org> wrote:
> > Author: stsp
> > Date: Fri Feb 25 10:01:57 2011
> > New Revision: 1074461
> >
> > URL: http://svn.apache.org/viewvc?rev=1074461&view=rev
> > Log:
> > Get rid of a few "missing sentinel" warnings from calls to apr_pstrcat()
> > by explicitly casting NULL to the expected pointer type.
> >
> > * subversion/libsvn_subr/dirent_uri.c
> >  (svn_fspath__canonicalize,
> >   svn_fspath__get_longest_ancestor): Cast to (char *).
> >
> > * subversion/libsvn_wc/relocate.c
> >  (svn_wc_relocate4): Same.
> >
> > * tools/client-side/svnmucc/svnmucc.c
> >  (main): Same.
> >
> > Modified:
> >    subversion/trunk/subversion/libsvn_subr/dirent_uri.c
> >    subversion/trunk/subversion/libsvn_wc/relocate.c
> >    subversion/trunk/tools/client-side/svnmucc/svnmucc.c
> >
> > Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
> > URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=1074461&r1=1074460&r2=1074461&view=diff
> > ==============================================================================
> > --- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
> > +++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Fri Feb 25 10:01:57 2011
> > @@ -2440,7 +2440,8 @@ svn_fspath__canonicalize(const char *fsp
> >   if ((fspath[0] == '/') && (fspath[1] == '\0'))
> >     return "/";
> >
> > -  return apr_pstrcat(pool, "/", svn_relpath_canonicalize(fspath, pool), NULL);
> > +  return apr_pstrcat(pool, "/", svn_relpath_canonicalize(fspath, pool),
> > +                     (char *)NULL);
> >  }
> >
> >
> > @@ -2571,7 +2572,7 @@ svn_fspath__get_longest_ancestor(const c
> >                        svn_relpath_get_longest_ancestor(fspath1 + 1,
> >                                                         fspath2 + 1,
> >                                                         result_pool),
> > -                       NULL);
> > +                       (char *)NULL);
> >
> >   assert(svn_fspath__is_canonical(result));
> >   return result;
> >
> > Modified: subversion/trunk/subversion/libsvn_wc/relocate.c
> > URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/relocate.c?rev=1074461&r1=1074460&r2=1074461&view=diff
> > ==============================================================================
> > --- subversion/trunk/subversion/libsvn_wc/relocate.c (original)
> > +++ subversion/trunk/subversion/libsvn_wc/relocate.c Fri Feb 25 10:01:57 2011
> > @@ -146,7 +146,7 @@ svn_wc_relocate4(svn_wc_context_t *wc_ct
> >   if (old_url_len == from_len)
> >     new_url = to;
> >   else
> > -    new_url = apr_pstrcat(scratch_pool, to, old_url + from_len, NULL);
> > +    new_url = apr_pstrcat(scratch_pool, to, old_url + from_len, (char *)NULL);
> >   if (! svn_path_is_url(new_url))
> >     return svn_error_createf(SVN_ERR_WC_INVALID_RELOCATION, NULL,
> >                              _("Invalid relocation destination: '%s' "
> >
> > Modified: subversion/trunk/tools/client-side/svnmucc/svnmucc.c
> > URL: http://svn.apache.org/viewvc/subversion/trunk/tools/client-side/svnmucc/svnmucc.c?rev=1074461&r1=1074460&r2=1074461&view=diff
> > ==============================================================================
> > --- subversion/trunk/tools/client-side/svnmucc/svnmucc.c (original)
> > +++ subversion/trunk/tools/client-side/svnmucc/svnmucc.c Fri Feb 25 10:01:57 2011
> > @@ -1071,7 +1071,8 @@ main(int argc, const char **argv)
> >                                                url), pool);
> >               /* ### These relpaths are already URI-encoded. */
> >               url = apr_pstrcat(pool, root_url, "/",
> > -                                svn_relpath_canonicalize(url, pool), NULL);
> > +                                svn_relpath_canonicalize(url, pool),
> > +                                (char *)NULL);
> >             }
> >           url = sanitize_url(url, pool);
> >           action->path[j] = url;
> >
> >
> >

Re: svn commit: r1074461 - in /subversion/trunk: subversion/libsvn_subr/dirent_uri.c subversion/libsvn_wc/relocate.c tools/client-side/svnmucc/svnmucc.c

Posted by Florian Weimer <fw...@bfk.de>.
* Greg Stein:

> What?! ... what is this? I've never seen "missing sentinel". This just
> seems to complicate the code for the sake of a compiler. And one that
> historically has not been a problem for us.

You cannot use NULL to terminate varargs lists which are expected to
consist of pointers because NULL may expand to 0 (without a cast to
void *), which gets promoted to long in the argument lsit.  This may
or may not be appropriate as a pointer value, depending on the
platform.

-- 
Florian Weimer                <fw...@bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99