Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Oct 2013 13:39:46 +0200
From:      Joerg Sonnenberger <joerg@britannica.bec.de>
To:        freebsd-hackers@freebsd.org, hackers@freebsd.org
Subject:   Re: warning spew from cddl libnvpair.c
Message-ID:  <20131025113946.GA15905@britannica.bec.de>
In-Reply-To: <1382672957.18382.11.camel@localhost>
References:  <1382672957.18382.11.camel@localhost>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Oct 24, 2013 at 11:49:17PM -0400, Sean Bruno wrote:
> libnvpair.c has some macros and preprocessor directives that make
> clang's -Wformat-security very unhappy.
> 
> /home/sbruno/bsd/head/cddl/lib/libnvpair/../../../cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c:245:1: warning: format string is not a string literal (po
> tentially insecure) [-Wformat-security]
> NVLIST_ARRPRTFUNC(byte_array, uchar_t, uchar_t, "0x%2.2x")
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbruno/bsd/head/cddl/lib/libnvpair/../../../cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c:238:23: note: expanded from macro 'NVLIST_ARRPRTFUNC'
>                         (void) fprintf(fp, pctl->nvprt_btwnarrfmt); \
> 
> 
> I don't see a real graceful way out of this.  Also, this is totally
> "legit" C, so I don't see any reason to generate these warnings.  Can
> someone educate me on either:
>   1.  fixing these warnings the right way
>   2.  how to disable the warning flags/makefile magic

You can wrap the statement with

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
// Evil code here
#pragma GCC diagnostic pop

and/or use the corresponding _Pragma.

Joerg



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