From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 10 01:09:12 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3EB4416A4CE for ; Tue, 10 Feb 2004 01:09:12 -0800 (PST) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0FEF543D31 for ; Tue, 10 Feb 2004 01:09:12 -0800 (PST) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id D73365310; Tue, 10 Feb 2004 10:09:10 +0100 (CET) Received: from dwp.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 7B06F530D for ; Tue, 10 Feb 2004 10:09:03 +0100 (CET) Received: by dwp.des.no (Postfix, from userid 2602) id 683E633C6F; Tue, 10 Feb 2004 10:09:03 +0100 (CET) To: hackers@freebsd.org From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Tue, 10 Feb 2004 10:09:03 +0100 Message-ID: User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on flood.des.no X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=AWL autolearn=no version=2.63 Subject: how to fool gcc? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2004 09:09:12 -0000 I'm having trouble with some uncommitted OpenPAM patches that I'd like to get into the tree. The problem actually doesn't occur with a normal build, but it prevents me from building a debugging version of libpam. Part of the patch declares openpam_log(3) as printf-like so gcc can check format strings etc. However, openpam_log(3) is also used in debugging macros such as this: #define RETURNS(s) do { \ if ((s) =3D=3D NULL) \ openpam_log(PAM_LOG_DEBUG, "returning NULL"); \ else \ openpam_log(PAM_LOG_DEBUG, "returning '%s'", (s)); \ return (s); \ } while (0) The problem is that when it encounters RETURNS(NULL), gcc complains that I'm passing a NULL argument to printf(3), even though it should be obvious that I'm not: cc -O -pipe -march=3Dpentium2 -I/usr/src/lib/libpam/libpam -I/home/des/proj= ects/openpam/include -DLIB_MAJ=3D2 -g -DDEBUG -Wsystem-headers -Werror -Wal= l -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-ari= th -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align= -Wbad-function-cast -Wchar-subscripts -Winline -Wnested-externs -Wredundan= t-decls -c /home/des/projects/openpam/lib/openpam_get_option.c /home/des/projects/openpam/lib/openpam_get_option.c: In function `openpam_g= et_option': /home/des/projects/openpam/lib/openpam_get_option.c:62: warning: reading th= rough null pointer (arg 4) /home/des/projects/openpam/lib/openpam_get_option.c:73: warning: reading th= rough null pointer (arg 4) *** Error code 1 Stop in /usr/src/lib/libpam/libpam. I've tried various twists to fool gcc, such as casting (s) to (const char *) and adding 0 to it hoping that the addition would defeat its NULL pointer check. Nothing I've tried works, though, and I would really hate to have to lower the WANRS level just for this. Any suggestions? DES --=20 Dag-Erling Sm=F8rgrav - des@des.no