You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by po...@apache.org on 2010/02/16 21:24:34 UTC

svn commit: r910673 - /httpd/httpd/trunk/server/config.c

Author: poirier
Date: Tue Feb 16 20:24:33 2010
New Revision: 910673

URL: http://svn.apache.org/viewvc?rev=910673&view=rev
Log:
Fix compile warning (discarding constness of fname)

Modified:
    httpd/httpd/trunk/server/config.c

Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=910673&r1=910672&r2=910673&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Tue Feb 16 20:24:33 2010
@@ -1670,7 +1670,7 @@
     int current;
 
     /* find the first part of the filename */
-    rest = ap_strchr(fname, '/');
+    rest = ap_strchr((char*)fname, '/');
     if (rest) {
         fname = apr_pstrndup(ptemp, fname, rest - fname);
         rest++;



Re: svn commit: r910673 - /httpd/httpd/trunk/server/config.c

Posted by Dan Poirier <po...@pobox.com>.
On Tue, Feb 16, 2010, at 03:30:21 PM, Jeff Trawick <tr...@gmail.com> wrote:

>> ==============================================================================
>> --- httpd/httpd/trunk/server/config.c (original)
>> +++ httpd/httpd/trunk/server/config.c Tue Feb 16 20:24:33 2010
>> @@ -1670,7 +1670,7 @@
>>     int current;
>>
>>     /* find the first part of the filename */
>> -    rest = ap_strchr(fname, '/');
>> +    rest = ap_strchr((char*)fname, '/');
>
> Casting isn't the right fix, which I guess is to make rest const char
> * and then use ap_strchr_c() instead of ap_strchr() (hopefully that
> doesn't snowball).

Thanks, that works without snowballing.

Re: svn commit: r910673 - /httpd/httpd/trunk/server/config.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Wed, Feb 17, 2010 at 9:23 AM, Barry Scott <ba...@onelan.co.uk> wrote:
> On 16/02/10 20:30, Jeff Trawick wrote:
>>
>> On Tue, Feb 16, 2010 at 3:24 PM,<po...@apache.org>  wrote:
>>
>>>
>>> Author: poirier
>>> Date: Tue Feb 16 20:24:33 2010
>>> New Revision: 910673
>>>
>>> URL: http://svn.apache.org/viewvc?rev=910673&view=rev
>>> Log:
>>> Fix compile warning (discarding constness of fname)
>>>
>>> Modified:
>>>    httpd/httpd/trunk/server/config.c
>>>
>>> Modified: httpd/httpd/trunk/server/config.c
>>> URL:
>>> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=910673&r1=910672&r2=910673&view=diff
>>>
>>> ==============================================================================
>>> --- httpd/httpd/trunk/server/config.c (original)
>>> +++ httpd/httpd/trunk/server/config.c Tue Feb 16 20:24:33 2010
>>> @@ -1670,7 +1670,7 @@
>>>     int current;
>>>
>>>     /* find the first part of the filename */
>>> -    rest = ap_strchr(fname, '/');
>>> +    rest = ap_strchr((char*)fname, '/');
>>>
>>
>> Casting isn't the right fix, which I guess is to make rest const char
>> * and then use ap_strchr_c() instead of ap_strchr() (hopefully that
>> doesn't snowball).
>>
>>
>
> This is  a common problem that the C RTL solves using the
> idiom of accepting a const char * as input and returning
> a char * as output:
>
> char *strchr(const char *s, int c);
>
> You may wish to fix the ap_strchr signature to follow the
> C standard solution rather then invite snow balling.

The C standard signatures for strchr() and strstr() are busted and
don't allow some simple program errors to be caught at compile time,
so httpd provides different flavors which take char * or const char *
as input depending on what operations on the returned pointer are
desired.  (You have to build in maintainer mode to trigger the compile
warnings for misuse of the httpd APIs.)  The fix was simply to use the
httpd APIs properly.

Re: svn commit: r910673 - /httpd/httpd/trunk/server/config.c

Posted by Barry Scott <ba...@onelan.co.uk>.
On 16/02/10 20:30, Jeff Trawick wrote:
> On Tue, Feb 16, 2010 at 3:24 PM,<po...@apache.org>  wrote:
>    
>> Author: poirier
>> Date: Tue Feb 16 20:24:33 2010
>> New Revision: 910673
>>
>> URL: http://svn.apache.org/viewvc?rev=910673&view=rev
>> Log:
>> Fix compile warning (discarding constness of fname)
>>
>> Modified:
>>     httpd/httpd/trunk/server/config.c
>>
>> Modified: httpd/httpd/trunk/server/config.c
>> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=910673&r1=910672&r2=910673&view=diff
>> ==============================================================================
>> --- httpd/httpd/trunk/server/config.c (original)
>> +++ httpd/httpd/trunk/server/config.c Tue Feb 16 20:24:33 2010
>> @@ -1670,7 +1670,7 @@
>>      int current;
>>
>>      /* find the first part of the filename */
>> -    rest = ap_strchr(fname, '/');
>> +    rest = ap_strchr((char*)fname, '/');
>>      
> Casting isn't the right fix, which I guess is to make rest const char
> * and then use ap_strchr_c() instead of ap_strchr() (hopefully that
> doesn't snowball).
>
>    
This is  a common problem that the C RTL solves using the
idiom of accepting a const char * as input and returning
a char * as output:

char *strchr(const char *s, int c);

You may wish to fix the ap_strchr signature to follow the
C standard solution rather then invite snow balling.

[This came up in discussing a const ading patch I proposed
to the Python sources on python dev mailing list.]

Barry


Barry



Re: svn commit: r910673 - /httpd/httpd/trunk/server/config.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Tue, Feb 16, 2010 at 3:24 PM,  <po...@apache.org> wrote:
> Author: poirier
> Date: Tue Feb 16 20:24:33 2010
> New Revision: 910673
>
> URL: http://svn.apache.org/viewvc?rev=910673&view=rev
> Log:
> Fix compile warning (discarding constness of fname)
>
> Modified:
>    httpd/httpd/trunk/server/config.c
>
> Modified: httpd/httpd/trunk/server/config.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=910673&r1=910672&r2=910673&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/config.c (original)
> +++ httpd/httpd/trunk/server/config.c Tue Feb 16 20:24:33 2010
> @@ -1670,7 +1670,7 @@
>     int current;
>
>     /* find the first part of the filename */
> -    rest = ap_strchr(fname, '/');
> +    rest = ap_strchr((char*)fname, '/');

Casting isn't the right fix, which I guess is to make rest const char
* and then use ap_strchr_c() instead of ap_strchr() (hopefully that
doesn't snowball).