From patchwork Wed Oct 8 17:51:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 5054841 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 69F859F349 for ; Wed, 8 Oct 2014 17:52:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 816E6201DD for ; Wed, 8 Oct 2014 17:52:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 60592201CD for ; Wed, 8 Oct 2014 17:52:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753516AbaJHRv7 (ORCPT ); Wed, 8 Oct 2014 13:51:59 -0400 Received: from mail-yh0-f49.google.com ([209.85.213.49]:41330 "EHLO mail-yh0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752640AbaJHRv7 (ORCPT ); Wed, 8 Oct 2014 13:51:59 -0400 Received: by mail-yh0-f49.google.com with SMTP id a41so4126150yho.8 for ; Wed, 08 Oct 2014 10:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=FQm8KqIYEflOZPhnKrKxnPZWXWMowIjU84BD/cyRaNs=; b=CkCrHv46EPE1G8ywQVJ8R/Bh5JhhppTTP5xpa8rp/ViIGbfcRJMBKZWKT6aYkytqDg 1QRKpGXxWAgC/mI65pgS9JR8OU+8xlVSEd4xDFV3iIl009NOpx5yGTdHv77OSxvefPfc dvt52yK4Io44Lgj1OTIPxp+sWu0/dt0UkxZP7/w+P7xf3rZhUBy7cWU2LVCXRnM3rSbr r6Plg9t5NR+Jn0H0W3nLnWcB7lmH+eHTWvDOXGpg36wOfFuDzpgmJ5TsqLAVxXs4Z2s4 KwNVKmHSGh1cwkZ5vSCMDo2AsgllAdl2ymY+TJoWYh+zRukpd16OM+LxoWZQ0skjoLb4 KgWQ== MIME-Version: 1.0 X-Received: by 10.236.138.227 with SMTP id a63mr5605757yhj.149.1412790718293; Wed, 08 Oct 2014 10:51:58 -0700 (PDT) Received: by 10.170.140.9 with HTTP; Wed, 8 Oct 2014 10:51:58 -0700 (PDT) In-Reply-To: <20141008093910.GB3181@casper.infradead.org> References: <795aaa7448d91bd59bcbea3d8e49b068a569409e.1411632579.git.tgraf@suug.ch> <20141007094508.GN23154@mwanda> <20141008093910.GB3181@casper.infradead.org> Date: Thu, 9 Oct 2014 01:51:58 +0800 X-Google-Sender-Auth: s1zevYzvJQtlb4u3rTcrILH-B6Q Message-ID: Subject: Re: [PATCH v2] sparse: Make -Werror turn warnigns into errors From: Christopher Li To: Thomas Graf Cc: Dan Carpenter , Linux-Sparse 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_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 On Wed, Oct 8, 2014 at 5:39 PM, Thomas Graf wrote: >> This just enables -Werror for everyone so now I can't run Sparse on >> itself now because there are old errors from 2007. > > The above change should merely have sparse fail upon an error and not > warnings unless you specifiy -Werror which I would consider expected > behaviour. Actually I realized that this "-Werror" patch is wrong. As it is, we can't actually make the full kernel check without hitting sparse errors interrupting the build. That is pretty unacceptable. We should reserve the "-Werror" for gcc. It means gcc should treat warning as error. We should have another option like "-Wsparse-error" for telling sparse to treat warning as error. Just like "-Wall" does not mean sparse should turn on all usual warnings. We have "-Wsparse-all" for that. I have the following patch renaming the option. BTW, I think sparse should only return error when "-Wsparse-error" was given. Any feed back? Chris More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/lib.c b/lib.c index 8395662..b1b18aa 100644 --- a/lib.c +++ b/lib.c @@ -150,7 +150,7 @@ void warning(struct position pos, const char * fmt, ...) { va_list args; - if (Werror) { + if (Wsparse_error) { va_start(args, fmt); do_error(pos, fmt, args); va_end(args); @@ -226,7 +226,7 @@ int Wdesignated_init = 1; int Wdo_while = 0; int Winit_cstring = 0; int Wenum_mismatch = 1; -int Werror = 0; +int Wsparse_error = 0; int Wnon_pointer_null = 1; int Wold_initializer = 1; int Wone_bit_signed_bitfield = 1; @@ -439,7 +439,7 @@ static const struct warning { { "designated-init", &Wdesignated_init }, { "do-while", &Wdo_while }, { "enum-mismatch", &Wenum_mismatch }, - { "error", &Werror }, + { "sparse-error", &Wsparse_error }, { "init-cstring", &Winit_cstring }, { "non-pointer-null", &Wnon_pointer_null }, { "old-initializer", &Wold_initializer }, @@ -471,7 +471,7 @@ static char **handle_onoff_switch(char *arg, char **next, co if (!strcmp(p, "sparse-all")) { for (i = 0; i < n; i++) { - if (*warnings[i].flag != WARNING_FORCE_OFF && warnings[i + if (*warnings[i].flag != WARNING_FORCE_OFF && warnings[i *warnings[i].flag = WARNING_ON; } } diff --git a/lib.h b/lib.h index dc01684..15b69fa 100644 --- a/lib.h +++ b/lib.h @@ -112,7 +112,7 @@ extern int Wdefault_bitfield_sign; extern int Wdesignated_init; extern int Wdo_while; extern int Wenum_mismatch; -extern int Werror; +extern int Wsparse_error; extern int Winit_cstring; extern int Wnon_pointer_null; extern int Wold_initializer; diff --git a/sparse.1 b/sparse.1 index acdce53..63fceb9 100644 --- a/sparse.1 +++ b/sparse.1 @@ -24,7 +24,7 @@ off those warnings, pass the negation of the associated warnin Turn on all sparse warnings, except for those explicitly disabled via \fB\-Wno\-something\fR. .TP -.B \-Werror +.B \-Wsparse\-error Turn all sparse warnings into errors. .TP .B \-Waddress\-space diff --git a/sparse.c b/sparse.c index 7d389b1..6b3324c 100644 --- a/sparse.c +++ b/sparse.c @@ -288,7 +288,7 @@ static void check_symbols(struct symbol_list *list) } } END_FOR_EACH_PTR(sym); - if (die_if_error) + if (Wsparse_error && die_if_error) exit(1); -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org