From patchwork Thu Feb 27 02:03:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 3729881 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0F803BF13A for ; Thu, 27 Feb 2014 02:13:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15D6520204 for ; Thu, 27 Feb 2014 02:13:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31C85201FE for ; Thu, 27 Feb 2014 02:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186AbaB0CNG (ORCPT ); Wed, 26 Feb 2014 21:13:06 -0500 Received: from smtprelay0063.hostedemail.com ([216.40.44.63]:59276 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752649AbaB0CNG (ORCPT ); Wed, 26 Feb 2014 21:13:06 -0500 X-Greylist: delayed 563 seconds by postgrey-1.27 at vger.kernel.org; Wed, 26 Feb 2014 21:13:06 EST Received: from smtprelay.hostedemail.com (ff-bigip1 [10.5.19.254]) by smtpgrave04.hostedemail.com (Postfix) with ESMTP id 94F34B1E69 for ; Thu, 27 Feb 2014 02:03:52 +0000 (UTC) Received: from filter.hostedemail.com (ff-bigip1 [10.5.19.254]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 22BAD9EA25; Thu, 27 Feb 2014 02:03:45 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::, RULES_HIT:41:334:355:368:369:379:541:800:960:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3865:3867:4321:4605:5007:7652:8603:10004:10026:10400:10450:10455:10848:11026:11658:11914:12296:12438:12517:12519:12555:13019:13069:13311:13357:14093:14097:19904:19999, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: sound27_5a67346a6033d X-Filterd-Recvd-Size: 2497 Received: from [192.168.1.157] (pool-96-251-49-11.lsanca.fios.verizon.net [96.251.49.11]) (Authenticated sender: joe@perches.com) by omf07.hostedemail.com (Postfix) with ESMTPA; Thu, 27 Feb 2014 02:03:41 +0000 (UTC) Message-ID: <1393466619.24588.65.camel@joe-AO722> Subject: [PATCH] sparse: Allow override of sizeof(bool) warning From: Joe Perches To: "H. Peter Anvin" , linux-sparse@vger.kernel.org Cc: Linux Kernel Mailing List Date: Wed, 26 Feb 2014 18:03:39 -0800 In-Reply-To: <530E8C2E.7080307@zytor.com> References: <530E6F76.1070605@zytor.com> <1393462087.24588.50.camel@joe-AO722> <530E8C2E.7080307@zytor.com> X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow an override to emit or not the sizeof(bool) warning Signed-off-by: Joe Perches --- evaluate.c | 3 ++- lib.c | 2 ++ lib.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/evaluate.c b/evaluate.c index 6655615..a45f59b 100644 --- a/evaluate.c +++ b/evaluate.c @@ -2057,7 +2057,8 @@ static struct symbol *evaluate_sizeof(struct expression *expr) } if (size == 1 && is_bool_type(type)) { - warning(expr->pos, "expression using sizeof bool"); + if (Wsizeof_bool) + warning(expr->pos, "expression using sizeof bool"); size = bits_in_char; } diff --git a/lib.c b/lib.c index bf3e91c..676b72e 100644 --- a/lib.c +++ b/lib.c @@ -225,6 +225,7 @@ int Wone_bit_signed_bitfield = 1; int Wparen_string = 0; int Wptr_subtraction_blows = 0; int Wreturn_void = 0; +int Wsizeof_bool = 1; int Wshadow = 0; int Wtransparent_union = 0; int Wtypesign = 0; @@ -437,6 +438,7 @@ static const struct warning { { "paren-string", &Wparen_string }, { "ptr-subtraction-blows", &Wptr_subtraction_blows }, { "return-void", &Wreturn_void }, + { "sizeof-bool", &Wsizeof_bool }, { "shadow", &Wshadow }, { "transparent-union", &Wtransparent_union }, { "typesign", &Wtypesign }, diff --git a/lib.h b/lib.h index f09b338..7e3432f 100644 --- a/lib.h +++ b/lib.h @@ -119,6 +119,7 @@ extern int Wone_bit_signed_bitfield; extern int Wparen_string; extern int Wptr_subtraction_blows; extern int Wreturn_void; +extern int Wsizeof_bool; extern int Wshadow; extern int Wtransparent_union; extern int Wtypesign;