From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 25 11:40:05 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4E1B8AF8; Fri, 25 Oct 2013 11:40:05 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from mo6-p00-ob.rzone.de (mo6-p00-ob.rzone.de [IPv6:2a01:238:20a:202:5300::1]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B23A82FDC; Fri, 25 Oct 2013 11:40:04 +0000 (UTC) X-RZG-AUTH: :JiIXek6mfvEEUpFQdo7Fj1/zg48CFjWjQv0cW+St/nW/auYssS93lfgJF/wLgTc= X-RZG-CLASS-ID: mo00 Received: from britannica.bec.de (ip-2-202-252-221.web.vodafone.de [2.202.252.221]) by smtp.strato.de (RZmta 32.11 DYNA|AUTH) with (TLSv1.0:DHE-RSA-AES256-SHA encrypted) ESMTPSA id 6057b9p9PB2KdQ ; Fri, 25 Oct 2013 13:39:47 +0200 (CEST) Received: by britannica.bec.de (sSMTP sendmail emulation); Fri, 25 Oct 2013 13:39:46 +0200 Date: Fri, 25 Oct 2013 13:39:46 +0200 From: Joerg Sonnenberger To: freebsd-hackers@freebsd.org, hackers@freebsd.org Subject: Re: warning spew from cddl libnvpair.c Message-ID: <20131025113946.GA15905@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org, hackers@freebsd.org References: <1382672957.18382.11.camel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1382672957.18382.11.camel@localhost> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2013 11:40:05 -0000 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