Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Feb 2004 13:46:54 +0300
From:      Zajcev Evgeny <zevlg@yandex.ru>
To:        des@des.no (Dag-Erling Smørgrav)
Cc:        hackers@freebsd.org
Subject:   Re: how to fool gcc?
Message-ID:  <82fzdjb49t.fsf@us.dmz.local>
In-Reply-To: <xzpad3r5mj4.fsf@dwp.des.no> (Dag-Erling Smørgrav's message of "Tue, 10 Feb 2004 10:09:03 %2B0100")
References:  <xzpad3r5mj4.fsf@dwp.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?82fzdjb49t.fsf>