From owner-freebsd-current@FreeBSD.ORG Sat Dec 3 22:55:56 2005 Return-Path: X-Original-To: current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CE8C816A41F for ; Sat, 3 Dec 2005 22:55:56 +0000 (GMT) (envelope-from ru@ip.net.ua) Received: from tigra.ip.net.ua (tigra.ip.net.ua [82.193.96.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id A9BED43D64 for ; Sat, 3 Dec 2005 22:55:55 +0000 (GMT) (envelope-from ru@ip.net.ua) Received: from localhost (rocky.ip.net.ua [82.193.96.2]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id jB3Mtr00003508 for ; Sun, 4 Dec 2005 00:55:53 +0200 (EET) (envelope-from ru@ip.net.ua) Received: from tigra.ip.net.ua ([82.193.96.10]) by localhost (rocky.ipnet [82.193.96.2]) (amavisd-new, port 10024) with LMTP id 02977-04-2 for ; Sun, 4 Dec 2005 00:55:51 +0200 (EET) Received: from heffalump.ip.net.ua (heffalump.ip.net.ua [82.193.96.213]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id jB3MtEWl003467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 4 Dec 2005 00:55:14 +0200 (EET) (envelope-from ru@ip.net.ua) Received: (from ru@localhost) by heffalump.ip.net.ua (8.13.4/8.13.4) id jB3MtHos087486 for current@FreeBSD.org; Sun, 4 Dec 2005 00:55:17 +0200 (EET) (envelope-from ru) Date: Sun, 4 Dec 2005 00:55:17 +0200 From: Ruslan Ermilov To: current@FreeBSD.org Message-ID: <20051203225517.GK960@ip.net.ua> References: <20051203224518.GJ960@ip.net.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="c8JyeaiReRNoiMDS" Content-Disposition: inline In-Reply-To: <20051203224518.GJ960@ip.net.ua> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at ip.net.ua Cc: Subject: Re: Beware of subtle bugs due to cpp(1) limitations! X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2005 22:55:56 -0000 --c8JyeaiReRNoiMDS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Dec 04, 2005 at 12:45:18AM +0200, Ruslan Ermilov wrote: > Hi there, >=20 > cpp(1) only supports integer expressions, so the following >=20 > #define FOO foo > #if FOO =3D=3D bar >=20 > will always evaluate to true, because "foo" and "bar" will > be treated as zeroes, as explained in cpp.info. >=20 > I've only scanned for _MACHINE_ARCH, because that's how I > discovered it, and there's a couple of places where the > code is broken: >=20 > sys/dev/isp/isp_freebsd.h:#if _MACHINE_ARCH =3D=3D sparc64 > sys/dev/ispfw/ispfw.c:#if _MACHINE_ARCH =3D=3D sparc64 > sys/dev/ispfw/ispfw.c:#if _MACHINE_ARCH =3D=3D sparc64 > sys/dev/ispfw/ispfw.c:#if _MACHINE_ARCH =3D=3D sparc64 > sys/gnu/fs/reiserfs/reiserfs_fs.h:#if (_MACHINE_ARCH =3D=3D amd64) > sys/netgraph/ng_vjc.c:#if _MACHINE_ARCH =3D=3D i386 > sys/netgraph/ng_vjc.c:#elif _MACHINE_ARCH =3D=3D alpha > sys/netgraph/ng_vjc.c:#error Unspported _MACHINE_ARCH >=20 > In these cases, the right tests would be #ifdef __sparc64__. > Other instances (of not _MACHINE_ARCH) may be harder to > fix. The ng_vjc.c is a nice example that clearly > demonstrates (without compiling the code) that it's > broken -- it's compiled on all architectures, but has > the following code: >=20 > #if _MACHINE_ARCH =3D=3D i386 > #define NG_VJC_TSTATE_PTR_TYPE &ng_parse_uint32_type > #elif _MACHINE_ARCH =3D=3D alpha > #define NG_VJC_TSTATE_PTR_TYPE &ng_parse_uint64_type > #else > #error Unspported _MACHINE_ARCH > #endif >=20 > The season for more bugs of this type is declared open! :-) >=20 ``cpp -Wundef'' will allow us to find all these bugs. Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --c8JyeaiReRNoiMDS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDkiJVqRfpzJluFF4RAn9FAJoC9GIS0riMKZb15/V5ouUl3V0BCACgjh++ a4TXSeJM94K9pUB1gNFdEIU= =gowy -----END PGP SIGNATURE----- --c8JyeaiReRNoiMDS--