From patchwork Fri Jul 31 19:27:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Camuso X-Patchwork-Id: 6915611 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 895639F39D for ; Fri, 31 Jul 2015 19:28:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9620C20495 for ; Fri, 31 Jul 2015 19:28:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CDA420460 for ; Fri, 31 Jul 2015 19:28:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751069AbbGaT2A (ORCPT ); Fri, 31 Jul 2015 15:28:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49204 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbbGaT2A (ORCPT ); Fri, 31 Jul 2015 15:28:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 6A781374A0B; Fri, 31 Jul 2015 19:28:00 +0000 (UTC) Received: from dhcp40-158.desklab.eng.bos.redhat.com (dhcp40-158.desklab.eng.bos.redhat.com [10.19.40.158] (may be forged)) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6VJRxE5003493; Fri, 31 Jul 2015 15:27:59 -0400 From: Tony Camuso To: josh@joshtriplett.org, linux-sparse@vger.kernel.org Cc: tcamuso@redhat.com, sparse@chrisli.org Subject: [PATCH 3/3 V3] Add Wall_off switch to disable errors and warnings Date: Fri, 31 Jul 2015 15:27:59 -0400 Message-Id: <1438370879-21792-1-git-send-email-tcamuso@redhat.com> In-Reply-To: <1438216001-8862-4-git-send-email-tcamuso@redhat.com> References: <1438216001-8862-4-git-send-email-tcamuso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 For using sparse as a tokenizer only. While it still parses semantics, it doesn't report any semantic errors, which is undesirable for some tasks like locating the KABI associations in a kernel source file. Signed-off-by: Tony Camuso --- lib.c | 20 +++++++++++++++++++- lib.h | 1 + parse.c | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib.c b/lib.c index 8dc5bcf..ef182ae 100644 --- a/lib.c +++ b/lib.c @@ -103,6 +103,9 @@ unsigned int hexval(unsigned int c) static void do_warn(const char *type, struct position pos, const char * fmt, va_list args) { + if (Wall_off) + return; + static char buffer[512]; const char *name; @@ -120,7 +123,7 @@ void info(struct position pos, const char * fmt, ...) { va_list args; - if (!show_info) + if (!show_info || Wall_off) return; va_start(args, fmt); do_warn("", pos, fmt, args); @@ -129,6 +132,9 @@ void info(struct position pos, const char * fmt, ...) static void do_error(struct position pos, const char * fmt, va_list args) { + if (Wall_off) + return; + static int errors = 0; die_if_error = 1; show_info = 1; @@ -151,6 +157,9 @@ void warning(struct position pos, const char * fmt, ...) { va_list args; + if (Wall_off) + return; + if (Wsparse_error) { va_start(args, fmt); do_error(pos, fmt, args); @@ -241,6 +250,7 @@ int Wtypesign = 0; int Wundef = 0; int Wuninitialized = 1; int Wvla = 1; +int Wall_off = 0; int dbg_entry = 0; int dbg_dead = 0; @@ -464,6 +474,7 @@ static const struct warning { { "undef", &Wundef }, { "uninitialized", &Wuninitialized }, { "vla", &Wvla }, + { "all_off", &Wall_off }, }; enum { @@ -479,6 +490,13 @@ static char **handle_onoff_switch(char *arg, char **next, const struct warning w char *p = arg + 1; unsigned i; + if (!strcmp(p, "all_off")) { + for (i = 0; i < n; i++) + *warnings[i].flag = WARNING_FORCE_OFF; + Wall_off = 1; + return NULL; + } + if (!strcmp(p, "sparse-all")) { for (i = 0; i < n; i++) { if (*warnings[i].flag != WARNING_FORCE_OFF && warnings[i].flag != &Wsparse_error) diff --git a/lib.h b/lib.h index 15b69fa..65e4836 100644 --- a/lib.h +++ b/lib.h @@ -127,6 +127,7 @@ extern int Wtypesign; extern int Wundef; extern int Wuninitialized; extern int Wvla; +extern int Wall_off; extern int dbg_entry; extern int dbg_dead; diff --git a/parse.c b/parse.c index 02275d8..d70dffb 100644 --- a/parse.c +++ b/parse.c @@ -2746,6 +2746,10 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis /* Just a type declaration? */ if (!ident) { + + if (Wall_off) + return token->next; + warning(token->pos, "missing identifier in declaration"); return expect(token, ';', "at the end of type declaration"); }