From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 10 02:42:53 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 D5C3116A4CE for ; Tue, 10 Feb 2004 02:42:53 -0800 (PST) Received: from relay.mortal.ru (unknown [62.16.86.250]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04DA843D86 for ; Tue, 10 Feb 2004 02:42:53 -0800 (PST) (envelope-from zevlg@yandex.ru) Received: from us.dmz.local (wus000.dmz.local [10.32.1.6]) by relay.mortal.ru (8.11.6/8.11.6) with ESMTP id i1AAgnJ30421; Tue, 10 Feb 2004 13:42:49 +0300 Received: from us.dmz.local (localhost.dmz.local [127.0.0.1]) by us.dmz.local (8.12.3/8.12.3) with ESMTP id i1AAkuwC002488; Tue, 10 Feb 2004 13:46:56 +0300 (MSK) (envelope-from zevlg@yandex.ru) Received: (from wtc05@localhost) by us.dmz.local (8.12.3/8.12.3/Submit) id i1AAksLX002487; Tue, 10 Feb 2004 13:46:54 +0300 (MSK) X-Authentication-Warning: us.dmz.local: wtc05 set sender to zevlg@yandex.ru using -f To: des@des.no (Dag-Erling Smørgrav) References: From: Zajcev Evgeny Date: Tue, 10 Feb 2004 13:46:54 +0300 In-Reply-To: (Dag-Erling Smørgrav's message of "Tue, 10 Feb 2004 10:09:03 +0100") Message-ID: <82fzdjb49t.fsf@us.dmz.local> User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.5 (cabbage, berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit cc: hackers@freebsd.org Subject: Re: 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 10:42:53 -0000 des@des.no (Dag-Erling Smørgrav) writes: > 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) == 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: > Maybe just have copy of `s' inside while statement? Something like: > #define RETURNS(s) do { \ > if ((s) == NULL) \ > openpam_log(PAM_LOG_DEBUG, "returning NULL"); \ > else \ > openpam_log(PAM_LOG_DEBUG, "returning '%s'", (s)); \ > return (s); \ > } while (0) -- lg