httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <...@engelschall.com>
Subject Re: [PATCH] ap_md5: unsigned char -> char !?
Date Tue, 27 Oct 1998 14:59:19 GMT

In article <3635B661.71D79658@Golux.Com> you wrote:
> Ralf S. Engelschall wrote:
>> 
>> Usually we could cast the argument to strlen() to this type, but IMHO it's more
>> correct to change the string argument type of the ap_md5() function to "const
>> char *" and instead do the cast to "const unsigned char *" for the string
>> variable when passing to ap_md5_binary().

> Actually, I disagree.  I think it is more appropriate to cast the
> argument to strlen() than to change the datatype declaration of
> the argument to the outer function.  The latter is concealing
> what's actually needed for the sake of appeasing a lib routine
> that doesn't care about the content of each byte (as long as it isn't
> '\0') anyway.

But the argument to ap_md5() has to be NUL-terminated, i.e. what one usually
knows as a "string" in C. And a string usually is declare "const char *" or
just "char *", but not really "unsigned const char *". The "unsigned" qualifier
is usually used when you have binary data. And for this ap_md5_binary() is
for. So I thought "const char *" is more appropriate for ap_md5() which takes
a "string". Hmmm... but ok, it doesn't really matter, Ken. Both types of casts
fix the warning, so I'm personally fine with casting the strlen() arg, too.
But we have to decide which cast we really like more. So, any more votes from
others which cast we should use?
                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Mime
View raw message