From owner-cvs-src@FreeBSD.ORG Tue Dec 18 13:08:18 2007 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8113B16A469; Tue, 18 Dec 2007 13:08:18 +0000 (UTC) (envelope-from rermilov@team.vega.ru) Received: from mail.vega.ru (infra.dev.vega.ru [90.156.167.14]) by mx1.freebsd.org (Postfix) with ESMTP id 222DB13C447; Tue, 18 Dec 2007 13:08:17 +0000 (UTC) (envelope-from rermilov@team.vega.ru) Received: from [87.242.97.68] (port=60776 helo=edoofus.dev.vega.ru) by mail.vega.ru with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68 (FreeBSD)) (envelope-from ) id 1J4cBE-000MdE-2P; Tue, 18 Dec 2007 13:08:16 +0000 Received: from edoofus.dev.vega.ru (localhost [127.0.0.1]) by edoofus.dev.vega.ru (8.14.2/8.14.2) with ESMTP id lBID84aj003578; Tue, 18 Dec 2007 16:08:04 +0300 (MSK) (envelope-from rermilov@team.vega.ru) Received: (from ru@localhost) by edoofus.dev.vega.ru (8.14.2/8.14.2/Submit) id lBID84hv003577; Tue, 18 Dec 2007 16:08:04 +0300 (MSK) (envelope-from rermilov@team.vega.ru) X-Authentication-Warning: edoofus.dev.vega.ru: ru set sender to rermilov@team.vega.ru using -f Date: Tue, 18 Dec 2007 16:08:04 +0300 From: Ruslan Ermilov To: Dag-Erling Smorgrav Message-ID: <20071218130804.GA3211@team.vega.ru> References: <200712181041.lBIAfCSk011869@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200712181041.lBIAfCSk011869@repoman.freebsd.org> User-Agent: Mutt/1.5.16 (2007-06-09) Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/lib/libfetch fetch.c ftp.c http.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Dec 2007 13:08:18 -0000 On Tue, Dec 18, 2007 at 10:41:12AM +0000, Dag-Erling Smorgrav wrote: > des 2007-12-18 10:41:12 UTC > > FreeBSD src repository > > Modified files: > lib/libfetch fetch.c ftp.c http.c > Log: > Old patch I had lying around: correctly cast the argument to is*(). > IWBNI gcc could warn about this the way it warns about printf() abuse. > > MFC after: 1 week > > Revision Changes Path > 1.40 +2 -2 src/lib/libfetch/fetch.c > 1.98 +10 -10 src/lib/libfetch/ftp.c > 1.80 +13 -12 src/lib/libfetch/http.c > These casts are bogus. is*() expect a value that's representable as either "unsigned char" or EOF, so the correct fix would be to either make underlying types "unsigned char" instead of "char", or cast an argument to "unsigned char". : #include : : void : foo(int x) : { : : printf("%d\n", x); : } : : int : main(void) : { : char c; : unsigned char uc; : : foo(EOF); /* will be printed as -1 */ : : c = 0xff; : foo(c); /* bug */ : foo((int)c); /* bug (cast is a no-op) */ : foo((unsigned char)c); /* good cast */ : : uc = 0xff; : foo(uc); /* ok */ : foo((int)uc); /* ok (no-op cast) */ : : return (0); : } Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer