httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Richards <p.richa...@elsevier.co.uk>
Subject Re: cvs commit: apache/src mod_proxy.c (fwd)
Date Wed, 03 Jul 1996 15:16:02 GMT
Ben Laurie writes:
 > > 
 > > The code is wrong, p should not be a "const char *", it's only used to
 > > pick up the error string from strerror and strerror returns a "char *".
 > > 
 > > The compiler warning is correct since the variable is not the same type
 > > as the return parameter.
 > 
 > Nah. An assignment from char * to const char * is legal. Vice versa is not.

I know it's legal, if it wasn't legal you'd have an error not a warning.

The warning is correct, the variable's declaration does not match the
type expected as specified by the function prototype, gcc 2.7.x creates
lots more warnings than earlier versions, it's more pedantic.

In this case the warning is genuinely harmless but correct the warning
properly not by casting to something it should have been in the first
place (the cast makes the const a complete waste of time anyway, even
if it had served some purpose in the first place, which it didn't).

It's very rare that sticking in a cast is the correct fix, it usually just
masks the real situation.

Mime
View raw message