cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Picky Metaware compiler

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 29 Aug 2006 22:27:41 +0200 (CEST)

On Tue, 29 Aug 2006, Gisle Vanem wrote:

> I've managed to build libcurl under DOS using Metware's High-C
> compiler. Most work involved changing config.dos.
> This compiler is rather picky and warns for hostip4.c / 351:
> for(i=0; (curr = (struct in_addr *)he->h_addr_list[i]); i++) {
>
> IMHO correctly:
> '=' encountered where '==' may have been intended.

Yeah, gcc does the same warning unless that extra level of paratheses are
used...

> Should I go ahead and fix these? Should simply be written as:
> for(i=0; (curr = (struct in_addr *)he->h_addr_list[i]) != NULL; i++) {

Personally I think we should strive to make assigns outside of conditionals,
but like in this case it just makes shorter code so I think it is a fine
example of using it.

But I too appreciate builds as warning-free as possible so I guess I have to
say that sure, modify these conditions. Even if it makes the code slightly
less elegant in my view.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-08-29