Re: isspace etc and (int) typecast

From: Guido Serassio <>
Date: Tue, 27 Mar 2007 13:16:37 +0200

Hi Henrik,

At 02.56 27/03/2007, Henrik Nordstrom wrote:
>Reviewing Squid-2.HEAD changes and sorting/grouping them a bit I
>stumbled over your change to add casts in various isspace() calls which
>looks a bit odd.
>- for (; i < hmsg->req_end && (isspace(hmsg->buf[i])); i++);
>+ for (; i < hmsg->req_end && (isspace((int) hmsg->buf[i])); i++);
>Generally this is not a safe cast. The ctype family of functions want
>the same kind of "C character" as returned by getchar etc. That's an
>integer carrying an unsigned char or -1.
>As it's a very common coding error most C libraries accept char input to
>these functions and might even produce correct results on high octets,
>but not all (some may even segfault).
>What was the warnings you fixed with these casts? I suspect you only
>silenced a valid warning here without fixing the cause..

Exactly these:



Guido Serassio
Acme Consulting S.r.l. - Microsoft Certified Partner
Via Lucia Savarino, 1 10098 - Rivoli (TO) - ITALY
Tel. : +39.011.9530135 Fax. : +39.011.9781115
Received on Tue Mar 27 2007 - 05:36:34 MDT

This archive was generated by hypermail pre-2.1.9 : Sun Apr 01 2007 - 12:00:01 MDT