[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: warning in 'base64' module
From: |
Bruno Haible |
Subject: |
Re: warning in 'base64' module |
Date: |
Wed, 11 Jan 2006 18:59:47 +0100 |
User-agent: |
KMail/1.5 |
Simon Josefsson wrote:
> bool
> isbase64 (char ch)
> {
> return to_uchar (ch) <= 255 && 0 <= b64[to_uchar (ch)];
> }
> ...
> Presumably the warning is because gcc believe an unsigned char cannot
> be larger than 255, but we didn't want to assume that since I don't
> think C89 guarantee it. Correct me if I'm wrong...
>
> Is there a clean fix?
bool
isbase64 (char ch)
{
return
#if UCHAR_MAX > 255
to_uchar (ch) <= 255
#else
true
#endif
&& 0 <= b64[to_uchar (ch)];
}
or
bool
isbase64 (char ch)
{
#if UCHAR_MAX > 255
if (to_uchar (ch) > 255)
return false;
#endif
return 0 <= b64[to_uchar (ch)];
}
Ugly, but a warning on which people stumble over and over again (because
it appears even without -Wall) is even worse. I work around this kind of
warning also in GNU gettext.
Bruno