cURL / Mailing Lists / curl-library / Single Mail

curl-library

Minor Inconsistent Use Of strequal()

From: Alexander J. Oss <alexoss_at_verizon.net>
Date: Wed, 11 Dec 2002 05:15:43 -0500

While plowing through libcurl 7.10.2 eliminating warnings that Borland C++
Builder generates, I came across line 318 of cookie.c:

 co->field1=strequal(ptr, "TRUE")+1; /* store information */

The problem here is that in some cases strequal() is a call to stricmp,
which is only documented as returning "<0, 0, or >0". In cookie.h, the
Cookie.field1 struct element is only supposed to have the values 1 or 2. I
think there's an incorrect assumption that strequal will only return 0 or 1.

How about:

co->field1 = strequal(ptr, "TRUE") ? (char)1 : (char)2;

-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
Received on 2002-12-11