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...@btopenworld.com> on 2012/10/18 22:17:09 UTC

Re: svn commit: r1398983 - in /subversion/trunk: ./ subversion/include/ subversion/libsvn_ra_serf/ subversion/mod_dav_svn/

> Author: cmpilato

> URL: http://svn.apache.org/viewvc?rev=1398983&view=rev
> Log:
> Reintegrate into trunk the 'http-dynamic-prop-namespaces' branch
> (using a simple 'svn merge BRANCH-URL' with a trunk@HEAD client!).

> Modified: subversion/trunk/subversion/mod_dav_svn/deadprops.c
> +static dav_prop_name *
> +propname_to_davname(const char *propname, [...]
> +{     [...]
> +      colon = strrchr((char *)propname, ':');

deadprops.c:134:26: cast discards '__attribute__((const))' qualifier from pointer target type

Why cast away 'const'?  Standard strrchr() accepts const.

Ugh... What's happening is 'httpd.h' is messing with the standard lib functions:

In /usr/include/apache2/httpd.h:
[[[
  /* The C library has functions that allow const to be silently dropped ...
     these macros detect the drop in maintainer mode, but use the native
     methods for normal builds  [...] */
AP_DECLARE(char *) ap_strrchr(char *s, int c);
AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c);

#ifdef AP_DEBUG
#  undef strrchr
#  define strrchr(s, c)  ap_strrchr(s,c)
#else
#  define ap_strrchr(s, c)       strrchr(s, c)
#  define ap_strrchr_c(s, c)     strrchr(s, c)
#endif
]]]

I'm doing an AP_DEBUG build.  If I remove the explicit cast, I see a different warning:

deadprops.c:134:7: warning: passing argument 1 of 'ap_strrchr' discards 'const' qualifier from pointer target type

So neither way works cleanly for me.

But that's an artifact of a badly designed HTTPD header -- it has no business forcing third-party users of HTTPD code to follow their chosen rules for stdlib functions.

We shouldn't have the explicit cast.

- Julian

Re: svn commit: r1398983 - in /subversion/trunk: ./ subversion/include/ subversion/libsvn_ra_serf/ subversion/mod_dav_svn/

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Julian Foad wrote on Thu, Oct 18, 2012 at 21:17:09 +0100:
> > Author: cmpilato
> 
> > URL: http://svn.apache.org/viewvc?rev=1398983&view=rev
> > Log:
> > Reintegrate into trunk the 'http-dynamic-prop-namespaces' branch
> > (using a simple 'svn merge BRANCH-URL' with a trunk@HEAD client!).
> 
> > Modified: subversion/trunk/subversion/mod_dav_svn/deadprops.c
> > +static dav_prop_name *
> > +propname_to_davname(const char *propname, [...]
> > +{     [...]
> > +      colon = strrchr((char *)propname, ':');
> 
> deadprops.c:134:26: cast discards '__attribute__((const))' qualifier from pointer target type
> 
> Why cast away 'const'?  Standard strrchr() accepts const.
> 
> Ugh... What's happening is 'httpd.h' is messing with the standard lib functions:
> 
> In /usr/include/apache2/httpd.h:
> [[[
>   /* The C library has functions that allow const to be silently dropped ...
>      these macros detect the drop in maintainer mode, but use the native
>      methods for normal builds  [...] */
> AP_DECLARE(char *) ap_strrchr(char *s, int c);
> AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c);
> 
> #ifdef AP_DEBUG
> #  undef strrchr
> #  define strrchr(s, c)  ap_strrchr(s,c)
> #else
> #  define ap_strrchr(s, c)       strrchr(s, c)
> #  define ap_strrchr_c(s, c)     strrchr(s, c)
> #endif
> ]]]
> 
> I'm doing an AP_DEBUG build.  If I remove the explicit cast, I see a different warning:
> 
> deadprops.c:134:7: warning: passing argument 1 of 'ap_strrchr' discards 'const' qualifier from pointer target type
> 
> So neither way works cleanly for me.
> 
> But that's an artifact of a badly designed HTTPD header -- it has no business forcing third-party users of HTTPD code to follow their chosen rules for stdlib functions.
> 
> We shouldn't have the explicit cast.
> 

Agree that httpd headers that consumers (us) have to include shouldn't
be changing the signatures of standard library functions.  If httpd does
that, we should ask them to stop doing it. :)

> - Julian