From patchwork Sat Nov 10 00:10:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10676769 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 70F7714E2 for ; Sat, 10 Nov 2018 00:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C6742F23E for ; Sat, 10 Nov 2018 00:10:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50CD12F252; Sat, 10 Nov 2018 00:10:59 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 B41EB2F1F2 for ; Sat, 10 Nov 2018 00:10:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728001AbeKJJxy (ORCPT ); Sat, 10 Nov 2018 04:53:54 -0500 Received: from mail-vk1-f202.google.com ([209.85.221.202]:39535 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbeKJJxy (ORCPT ); Sat, 10 Nov 2018 04:53:54 -0500 Received: by mail-vk1-f202.google.com with SMTP id k8so873265vke.6 for ; Fri, 09 Nov 2018 16:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=tsKcqAn57U3VV3uRHCVxOYpyZ2jKvFqr/oH0KKan0tg=; b=ZKiTCOUsBy1O+Su1BsPHbxncO+QXSHTdevsxh8zN7y4XvkPzFjUzkwNlu+rwaSocdd RmkFp9JcsbTOENHFYH/s+eLeJKrzf+TFaBcFyIW3iKZfDuC7/71D/UfGcYtTTrPAgW5y OfokC00P/oHZRNN0w0K2Sa86wtAJZQZkA25v0vf6k/Rc4BAwjHx6Y421hvhWUKv6s2QU ewdQL1qXpKO6DouJ0mNJsE9lluveTzRp6MtIQm9VXBOmNhtjW79byytbEyqRIneMWKBn eSrC5SGDkB27WCxHEZZbuRXXoG/iynSoKF/j4gYzz1DfCqqNrDC1OQ+q7Wd9mEPyk3ht WcJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=tsKcqAn57U3VV3uRHCVxOYpyZ2jKvFqr/oH0KKan0tg=; b=mr43j2PIQqmg+p5DhXJoMsbI5QUdaAFx06s/35EkdiexYCTVMlFX0hP+aBIPegl7fI xoPr2DNjcFc1hwef+uw8YeiLD5YLOK95j3/QZCu7kBmFf7cXxVtDvDn8eREhqtLooArJ XgS5CyYNyq/hKAZHO5lDfN/Fftqkc8eJO+OnYEP6cYtM594D7152PlYtiZoHN5wSsgrm 5XUfCMVAt1pz9aVfoxafBvvwr/yhkkuMnvWOC0tdzPshpr76IoQK4LHgtk2LuCWoUU15 mSlTDzWOQG/AIRnz4V6Y5Au24HwvmNQiNrb4W+RjWJfYt1/qnHO18J0MjdqU53eJ0nmF IY1A== X-Gm-Message-State: AGRZ1gII5dGzNdxzP2Vl5WGBwOQ+8cmlUHE/mPksW5iCX1Ce8bXq5+rm pZ00JA7LSjdQhgCDTyD/UIe+rx0E7Si6 X-Google-Smtp-Source: AJdET5cdaSuwV+FOUoETH9cKyXCqf0lnpCzcoei0avqwEbn0KPe4h7WDPKQS30w50ObQutqDmo51JfK+X8ie X-Received: by 2002:ab0:3347:: with SMTP id h7mr9328345uap.4.1541808655352; Fri, 09 Nov 2018 16:10:55 -0800 (PST) Date: Fri, 9 Nov 2018 16:10:52 -0800 In-Reply-To: <20181108205255.193402-1-sbeller@google.com> Message-Id: <20181110001052.101290-1-sbeller@google.com> Mime-Version: 1.0 References: <20181108205255.193402-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH] coccicheck: introduce 'pending' semantic patches From: Stefan Beller To: sbeller@google.com Cc: git@vger.kernel.org, jonathantanmy@google.com, szeder.dev@gmail.com, martin.agren@gmail.com, gitster@pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: SZEDER Gábor Teach `make coccicheck` to avoid patches named "*.pending.cocci" and handle them separately in a new `make coccicheck-pending` instead. This means that we can separate "critical" patches from "FYI" patches. The former target can continue causing Travis to fail its static analysis job, while the latter can let us keep an eye on ongoing (pending) transitions without them causing too much fallout. Document the intended use-cases around these two targets. As the process around the pending patches is not yet fully explored, leave that out. Based-on-work-by: SZEDER Gábor Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano Reviewed-by: Josh Steadmon Signed-off-by: SZEDER Gábor --- I dialed back on the workflow, as we may want to explore it first before writing it down. Stefan Makefile | 7 +++++-- contrib/coccinelle/README | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bbfbb4292d..6bc4654828 100644 --- a/Makefile +++ b/Makefile @@ -2740,9 +2740,12 @@ endif then \ echo ' ' SPATCH result: $@; \ fi -coccicheck: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.cocci)) +coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/coccinelle/*.cocci))) -.PHONY: coccicheck +# See contrib/coccinelle/README +coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci)) + +.PHONY: coccicheck coccicheck-pending ### Installation rules diff --git a/contrib/coccinelle/README b/contrib/coccinelle/README index 9c2f8879c2..f0e80bd7f0 100644 --- a/contrib/coccinelle/README +++ b/contrib/coccinelle/README @@ -1,2 +1,43 @@ This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/) semantic patches that might be useful to developers. + +There are two types of semantic patches: + + * Using the semantic transformation to check for bad patterns in the code; + The target 'make coccicheck' is designed to check for these patterns and + it is expected that any resulting patch indicates a regression. + The patches resulting from 'make coccicheck' are small and infrequent, + so once they are found, they can be sent to the mailing list as per usual. + + Example for introducing new patterns: + 67947c34ae (convert "hashcmp() != 0" to "!hasheq()", 2018-08-28) + b84c783882 (fsck: s/++i > 1/i++/, 2018-10-24) + + Example of fixes using this approach: + 248f66ed8e (run-command: use strbuf_addstr() for adding a string to + a strbuf, 2018-03-25) + f919ffebed (Use MOVE_ARRAY, 2018-01-22) + + These types of semantic patches are usually part of testing, c.f. + 0860a7641b (travis-ci: fail if Coccinelle static analysis found something + to transform, 2018-07-23) + + * Using semantic transformations in large scale refactorings throughout + the code base. + + When applying the semantic patch into a real patch, sending it to the + mailing list in the usual way, such a patch would be expected to have a + lot of textual and semantic conflicts as such large scale refactorings + change function signatures that are used widely in the code base. + A textual conflict would arise if surrounding code near any call of such + function changes. A semantic conflict arises when other patch series in + flight introduce calls to such functions. + + So to aid these large scale refactorings, semantic patches can be used. + However we do not want to store them in the same place as the checks for + bad patterns, as then automated builds would fail. + That is why semantic patches 'contrib/coccinelle/*.pending.cocci' + are ignored for checks, and can be applied using 'make coccicheck-pending'. + + This allows to expose plans of pending large scale refactorings without + impacting the bad pattern checks.