From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4131C2BBCA for ; Wed, 16 Dec 2020 04:45:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E11923339 for ; Wed, 16 Dec 2020 04:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725940AbgLPEpZ (ORCPT ); Tue, 15 Dec 2020 23:45:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:50472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbgLPEpZ (ORCPT ); Tue, 15 Dec 2020 23:45:25 -0500 Date: Tue, 15 Dec 2020 20:45:09 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1608093909; bh=1KeAScfFlIO9L/LeyYrahKQ932yGqnpx4gtc9KVVclo=; h=From:To:Subject:In-Reply-To:From; b=ajAfYiE/Wv4L4t7dJW1/dMbgFfdlSL0JlxsM6tRTOARrzht/PvBs7kdIQvez2px7S FXKYIhiH7b6CZFQabwmK87Kfuq6aPbs45rNQrhgK0tj5xV5EwJ9evqOfhxUxSbzHy4 YSxWrRDPuBiHIKl7NgO/NMdjI2oylBrao6uS/fmM= From: Andrew Morton To: akpm@linux-foundation.org, joe@perches.com, linux-mm@kvack.org, lukas.bulwahn@gmail.com, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, yashsri421@gmail.com Subject: [patch 52/95] checkpatch: add fix option for LOGICAL_CONTINUATIONS Message-ID: <20201216044509.mjR-i-1iL%akpm@linux-foundation.org> In-Reply-To: <20201215204156.f05ec694b907845bcfab5c44@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org From: Aditya Srivastava Subject: checkpatch: add fix option for LOGICAL_CONTINUATIONS Currently, checkpatch warns if logical continuations are placed at the start of a line and not at the end of previous line. E.g., running checkpatch on commit 3485507fc272 ("staging: bcm2835-camera: Reduce length of enum names") reports: CHECK:LOGICAL_CONTINUATIONS: Logical continuations should be on the previous line + if (!ret + && camera_port == Provide a simple fix by inserting logical operator at the last non-comment, non-whitespace char of the previous line and removing from current line, if both the lines are additions(ie start with '+') Link: https://lkml.kernel.org/r/20201123102818.24364-1-yashsri421@gmail.com Signed-off-by: Aditya Srivastava Acked-by: Joe Perches Cc: Lukas Bulwahn Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/scripts/checkpatch.pl~checkpatch-add-fix-option-for-logical_continuations +++ a/scripts/checkpatch.pl @@ -3545,8 +3545,16 @@ sub process { # check for && or || at the start of a line if ($rawline =~ /^\+\s*(&&|\|\|)/) { - CHK("LOGICAL_CONTINUATIONS", - "Logical continuations should be on the previous line\n" . $hereprev); + my $operator = $1; + if (CHK("LOGICAL_CONTINUATIONS", + "Logical continuations should be on the previous line\n" . $hereprev) && + $fix && $prevrawline =~ /^\+/) { + # insert logical operator at last non-comment, non-whitepsace char on previous line + $prevline =~ /[\s$;]*$/; + my $line_end = substr($prevrawline, $-[0]); + $fixed[$fixlinenr - 1] =~ s/\Q$line_end\E$/ $operator$line_end/; + $fixed[$fixlinenr] =~ s/\Q$operator\E\s*//; + } } # check indentation starts on a tab stop _