From patchwork Tue Dec 7 12:54:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1564685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=e/dIiEiK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J7gHQ5bHJz9s3q for ; Tue, 7 Dec 2021 23:54:42 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8B3CA3C4D66 for ; Tue, 7 Dec 2021 13:54:39 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id E9BF63C0BCC for ; Tue, 7 Dec 2021 13:54:36 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 49EAC1400E72 for ; Tue, 7 Dec 2021 13:54:35 +0100 (CET) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 813CC21954; Tue, 7 Dec 2021 12:54:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1638881675; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pY3ZsLqAUuDkCXdI0bX+ix9JM8J4bUcjsKECbG7+4T8=; b=e/dIiEiKh+iFgcJcaepA1nWHGfkHQZ0fc6cXsH0NZDaGOclAayugQ7XsJhurzljsm/lHPI ySqzoZSGojaW8wrAVP7khUNUgDPJfLPIH7RrHDRNWm17kELLu3s5nT5CM+1eXGJI96PWrh zk78bD9XwVIEPljn96tMSYcS3pruMro= Received: from g78.suse.de (unknown [10.163.17.14]) by relay2.suse.de (Postfix) with ESMTP id 3F5B8A3B84; Tue, 7 Dec 2021 12:54:35 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 7 Dec 2021 12:54:20 +0000 Message-Id: <20211207125420.32538-1-rpalethorpe@suse.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211130114527.5942-1-chrubis@suse.cz> References: <20211130114527.5942-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH] check: Deprecated API symbols X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The old API represents a big source of complication. It invalidates a lot of assumptions we can make when writing checks specifically for the new API. Cyril proposed ignoring these symbols altogether in a previous patch. This is a counter proposal to print a warning, but then abandon checking the symbol any further. The reasoning is that ignoring them altogether might hide errors. Also the existence of the old API may be a surprise to new developers. This change will alert them that a test needs updating and that it is not to be used as a reference. Signed-off-by: Richard Palethorpe Reviewed-by: Cyril Hrubis --- tools/sparse/sparse-ltp.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/sparse/sparse-ltp.c b/tools/sparse/sparse-ltp.c index 3a38229f1..513033518 100644 --- a/tools/sparse/sparse-ltp.c +++ b/tools/sparse/sparse-ltp.c @@ -81,6 +81,32 @@ static void do_entrypoint_checks(struct entrypoint *ep) do_basicblock_checks(bb); } END_FOR_EACH_PTR(bb); } +/* The old API can not comply with the rules. So when we see one of + * these symbols we know that it will result in further + * warnings. Probably these will suggest inappropriate things. Usually + * these symbols should be removed and the new API used + * instead. Otherwise they can be ignored until all tests have been + * converted to the new API. + */ +static bool check_symbol_deprecated(const struct symbol *const sym) +{ + static struct ident *TCID_id, *TST_TOTAL_id; + const struct ident *id = sym->ident; + + if (!TCID_id) { + TCID_id = built_in_ident("TCID"); + TST_TOTAL_id = built_in_ident("TST_TOTAL"); + } + + if (id != TCID_id && id != TST_TOTAL_id) + return false; + + warning(sym->pos, + "Ignoring deprecated API symbol: '%s'. Should this code be converted to the new API?", + show_ident(id)); + + return true; +} /* Check for LTP-003 and LTP-004 * @@ -212,6 +238,9 @@ static void check_test_struct(const struct symbol *const sym) /* AST level checks */ static void do_symbol_checks(struct symbol *sym) { + if (check_symbol_deprecated(sym)) + return; + check_symbol_visibility(sym); check_test_struct(sym); }