From patchwork Sun Jan 20 00:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10772237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D976D13B4 for ; Sun, 20 Jan 2019 00:14:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9AE1289E1 for ; Sun, 20 Jan 2019 00:14:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDCF928A5A; Sun, 20 Jan 2019 00:14:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19575289E1 for ; Sun, 20 Jan 2019 00:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729889AbfATAOB (ORCPT ); Sat, 19 Jan 2019 19:14:01 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34417 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729895AbfATAOA (ORCPT ); Sat, 19 Jan 2019 19:14:00 -0500 Received: by mail-wr1-f65.google.com with SMTP id j2so19387216wrw.1 for ; Sat, 19 Jan 2019 16:13:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JR41//v1drAz7wBCE89dGfV709T41RW8lIrAWUeCFeA=; b=CXBAusnYcyL4j+jvOHC+ETFP+3r5k9iICcFsnIpMv3ihijEnpQDj/43OsSfaPLhFl5 AgvowDMn2Z3Cf0Fz9Wa+OPkr5ds+Nb687onz2t9RWiQrykCmz9Dj/opsoz/5/JFmpzIC sTNcnaMboqaCLS3A9XkwDMTVENfw4oICwzx4xL4Kq9qir+IvFIYfs0oq/dQ1OAfFRTUz CNtu8KjPMakWMnSwexic59WEueZZqwLmQl5ZFGglfwUjNBGH7qsuxFbbnXXkKeaXpzoQ 1ndv9QAf3+x03IxMv7tR2WCaacOHzpEUASA1fQl53NBy5AS+dSaNuJGvSLERY/Q6zE8U mDBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JR41//v1drAz7wBCE89dGfV709T41RW8lIrAWUeCFeA=; b=T+6Wra0zyUu/Q6q9SCmdkLdsz6J/Ucah0YuLQ9h3+Bt5nX5UjJOM9rvRosjMj8YS65 XgKAZzzWk8UG2oCExcCxjrfl9vFC0SbDi7cDNGq00ccH4ZZyuP36jTxFcjQartJaIOYd gJUlHIXSEIbtrl/ZbxwWPOEmEEjcjqWBLfz5hXu+0N6S13/saidgbCXkzSEXHZ6LUS2v a4RPRUlB3b0tZV+kwLwrLk6iXklrZigdMal3tL5+zhBjy4M8spUGq+B48kl/GFsTXfU7 G4TS2A9br6Wir/wrLbHw5v3mTmJI3xLQmk++MequX6TqRNGHmx18GMu7GeMo6DWvdEUU FoaQ== X-Gm-Message-State: AJcUukdBtnOHQhw4YEMT6KDT1uMM5VFoNVKckDTq4EWt9vz4OccV+kOW Hnmwjq8UWnQwhdROhO/oFgM8rf4l X-Google-Smtp-Source: ALg8bN7chLy/eGw4FTEE5IwwkYync/2t5UkQO/xZON8vKveIRygOxnjiUS0JHfGO/4ZCsZ+C3tojeA== X-Received: by 2002:adf:e407:: with SMTP id g7mr11604103wrm.277.1547943236945; Sat, 19 Jan 2019 16:13:56 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:40eb:400:dc79:225f:308a:97fa]) by smtp.gmail.com with ESMTPSA id x15sm100991673wrs.27.2019.01.19.16.13.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jan 2019 16:13:56 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/2] more consistent type info in error messages Date: Sun, 20 Jan 2019 01:13:50 +0100 Message-Id: <20190120001350.19987-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190120001350.19987-1-luc.vanoostenryck@gmail.com> References: <20190120001350.19987-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some error messages are displayed with auxillary information about the concerned type(s). However, this type information is displayed in various way: just the type, "[left/right] side has type ...", "got ...", ... Make these more consistent and simpler by simply dipslaying type(s) when the error message is unambigous about the fact that the problem is a type problem (and/or make the message unambiguous when possible). Signed-off-by: Luc Van Oostenryck --- evaluate.c | 20 ++++++++++---------- validation/bad-type-twice0.c | 4 ++-- validation/bad-type-twice1.c | 6 +++--- validation/compare-null-to-int.c | 6 +++--- validation/cond_expr.c | 4 ++-- validation/conditional-type.c | 32 ++++++++++++++++---------------- validation/enum-mismatch.c | 6 +++--- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/evaluate.c b/evaluate.c index efe6d28b8..4d5748562 100644 --- a/evaluate.c +++ b/evaluate.c @@ -283,9 +283,9 @@ warn_for_different_enum_types (struct position pos, return; if (typea->type == SYM_ENUM && typeb->type == SYM_ENUM) { - warning(pos, "mixing different enum types"); - info(pos, " %s versus", show_typename(typea)); - info(pos, " %s", show_typename(typeb)); + warning(pos, "mixing different enum types:"); + info(pos, " %s", show_typename(typea)); + info(pos, " %s", show_typename(typeb)); } } @@ -413,16 +413,16 @@ static struct symbol *bad_expr_type(struct expression *expr) case EXPR_COMPARE: if (!valid_subexpr_type(expr)) break; - sparse_error(expr->pos, "incompatible types for operation (%s)", show_special(expr->op)); - info(expr->pos, " left side has type %s", show_typename(expr->left->ctype)); - info(expr->pos, " right side has type %s", show_typename(expr->right->ctype)); + sparse_error(expr->pos, "incompatible types for operation (%s):", show_special(expr->op)); + info(expr->pos, " %s", show_typename(expr->left->ctype)); + info(expr->pos, " %s", show_typename(expr->right->ctype)); break; case EXPR_PREOP: case EXPR_POSTOP: if (!valid_expr_type(expr->unop)) break; - sparse_error(expr->pos, "incompatible types for operation (%s)", show_special(expr->op)); - info(expr->pos, " argument has type %s", show_typename(expr->unop->ctype)); + sparse_error(expr->pos, "incompatible type for operation (%s):", show_special(expr->op)); + info(expr->pos, " %s", show_typename(expr->unop->ctype)); break; default: break; @@ -910,8 +910,8 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator if (Waddress) warning(expr->pos, "the address of %s will always evaluate as true", "an array"); } else if (!is_scalar_type(ctype)) { - sparse_error(expr->pos, "incorrect type in conditional"); - info(expr->pos, " got %s", show_typename(ctype)); + sparse_error(expr->pos, "incorrect type in conditional:"); + info(expr->pos, " %s", show_typename(ctype)); return NULL; } diff --git a/validation/bad-type-twice0.c b/validation/bad-type-twice0.c index 7a9073c52..84e0f25a4 100644 --- a/validation/bad-type-twice0.c +++ b/validation/bad-type-twice0.c @@ -7,7 +7,7 @@ static int foo(a) * check-name: bad-type-twice0 * * check-error-start -bad-type-twice0.c:3:16: error: incorrect type in conditional -bad-type-twice0.c:3:16: got incomplete type a +bad-type-twice0.c:3:16: error: incorrect type in conditional: +bad-type-twice0.c:3:16: incomplete type a * check-error-end */ diff --git a/validation/bad-type-twice1.c b/validation/bad-type-twice1.c index cc81662af..a9ba182cb 100644 --- a/validation/bad-type-twice1.c +++ b/validation/bad-type-twice1.c @@ -9,8 +9,8 @@ static unsigned long foo(unsigned long val, void *ref) * check-name: bad-type-twice1 * * check-error-start -bad-type-twice1.c:3:17: error: incompatible types for operation (>=) -bad-type-twice1.c:3:17: left side has type unsigned long val -bad-type-twice1.c:3:17: right side has type void *ref +bad-type-twice1.c:3:17: error: incompatible types for operation (>=): +bad-type-twice1.c:3:17: unsigned long val +bad-type-twice1.c:3:17: void *ref * check-error-end */ diff --git a/validation/compare-null-to-int.c b/validation/compare-null-to-int.c index 08e556b32..336c724de 100644 --- a/validation/compare-null-to-int.c +++ b/validation/compare-null-to-int.c @@ -4,8 +4,8 @@ static unsigned int comparison = (void *)0 == 1; * check-description: Sparse used to allow this. * * check-error-start -compare-null-to-int.c:1:44: error: incompatible types for operation (==) -compare-null-to-int.c:1:44: left side has type void * -compare-null-to-int.c:1:44: right side has type int +compare-null-to-int.c:1:44: error: incompatible types for operation (==): +compare-null-to-int.c:1:44: void * +compare-null-to-int.c:1:44: int * check-error-end */ diff --git a/validation/cond_expr.c b/validation/cond_expr.c index e55711cce..9b8105c1c 100644 --- a/validation/cond_expr.c +++ b/validation/cond_expr.c @@ -13,7 +13,7 @@ int a(void) * check-name: Two-argument conditional expression types * * check-error-start -cond_expr.c:10:16: error: incompatible types for operation (~) -cond_expr.c:10:16: argument has type double +cond_expr.c:10:16: error: incompatible type for operation (~): +cond_expr.c:10:16: double * check-error-end */ diff --git a/validation/conditional-type.c b/validation/conditional-type.c index a14c05ec1..7cd5672dc 100644 --- a/validation/conditional-type.c +++ b/validation/conditional-type.c @@ -79,21 +79,21 @@ static int good_if_ptr(void *ptr) * check-name: conditional-type * * check-error-start -conditional-type.c:18:18: error: incorrect type in conditional -conditional-type.c:18:18: got void -conditional-type.c:19:13: error: incorrect type in conditional -conditional-type.c:19:13: got struct state s -conditional-type.c:24:18: error: incorrect type in conditional -conditional-type.c:24:18: got void -conditional-type.c:29:21: error: incorrect type in conditional -conditional-type.c:29:21: got void -conditional-type.c:30:16: error: incorrect type in conditional -conditional-type.c:30:16: got struct state s -conditional-type.c:34:21: error: incorrect type in conditional -conditional-type.c:34:21: got void -conditional-type.c:36:20: error: incorrect type in conditional -conditional-type.c:36:20: got void -conditional-type.c:40:21: error: incorrect type in conditional -conditional-type.c:40:21: got void +conditional-type.c:18:18: error: incorrect type in conditional: +conditional-type.c:18:18: void +conditional-type.c:19:13: error: incorrect type in conditional: +conditional-type.c:19:13: struct state s +conditional-type.c:24:18: error: incorrect type in conditional: +conditional-type.c:24:18: void +conditional-type.c:29:21: error: incorrect type in conditional: +conditional-type.c:29:21: void +conditional-type.c:30:16: error: incorrect type in conditional: +conditional-type.c:30:16: struct state s +conditional-type.c:34:21: error: incorrect type in conditional: +conditional-type.c:34:21: void +conditional-type.c:36:20: error: incorrect type in conditional: +conditional-type.c:36:20: void +conditional-type.c:40:21: error: incorrect type in conditional: +conditional-type.c:40:21: void * check-error-end */ diff --git a/validation/enum-mismatch.c b/validation/enum-mismatch.c index 1bdb1d6c2..a6e5d72db 100644 --- a/validation/enum-mismatch.c +++ b/validation/enum-mismatch.c @@ -12,8 +12,8 @@ static enum eb foo(enum ea a) * check-command: sparse -Wenum-mismatch $file * * check-error-start -enum-mismatch.c:7:16: warning: mixing different enum types -enum-mismatch.c:7:16: unsigned int enum ea versus -enum-mismatch.c:7:16: unsigned int enum eb +enum-mismatch.c:7:16: warning: mixing different enum types: +enum-mismatch.c:7:16: unsigned int enum ea +enum-mismatch.c:7:16: unsigned int enum eb * check-error-end */