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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 141EAC388F9 for ; Sat, 21 Nov 2020 21:04:55 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78DA920825 for ; Sat, 21 Nov 2020 21:04:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d/4PPvJn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 78DA920825 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id EB84C86A3C; Sat, 21 Nov 2020 21:04:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zx1S47VDdJrx; Sat, 21 Nov 2020 21:04:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 6B985869F3; Sat, 21 Nov 2020 21:04:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 43AB2C1825; Sat, 21 Nov 2020 21:04:53 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7CFFCC0891 for ; Sat, 21 Nov 2020 21:04:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 706A2869F3 for ; Sat, 21 Nov 2020 21:04:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yJ4I9Q7lTf73 for ; Sat, 21 Nov 2020 21:04:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by whitealder.osuosl.org (Postfix) with ESMTPS id E9BC5862DE for ; Sat, 21 Nov 2020 21:04:51 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id t21so10564578pgl.3 for ; Sat, 21 Nov 2020 13:04:51 -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; bh=GbxAeOvJk7Tb/1c/SoKJjtp//xhRkqyZpZjDLBwDuU8=; b=d/4PPvJnTT35ihukdVwL1ye3WWxs6SkZzriQulEtZ1jdu8SwZPkCDXrCiej90IV2fk AmPb8dFqqWRfXLUlnHhG2+wC+HQEdhJJjtpS6oTZ7RDRHthu3Tf5AXxVlYTm8w9hfqyZ clLKl5+X9fentMD7xJX+ROtTgMij9kPihoiTGynETRBiI+KY60sFzBey6lL66Pk/l+NZ VbN5u+yg2ztSTP28Ae4haXaxJAfARSxaGSDkOHGwDPgLffosJaLvNJq1kp9pnsuY+w2i Cz6NmEVCT/M2sB3fH3M/P8ERnVjuQkZnWuHjfMNZvOrOsZDU5Y8Gd0MGEddQk1Kiii7A h39g== 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; bh=GbxAeOvJk7Tb/1c/SoKJjtp//xhRkqyZpZjDLBwDuU8=; b=iJm6CG6/EzdE/7DomJ9EyWMWrxV/oJSHCnCxFlBAzrXGYMlLgeOtRM/Xh9Kdure2+m CMfpWCUx24RYE0cc1n5Dcz2GjHNu5pYLZDvV1ipaY6+3qbm+QJV5TGFjRsI2oCvkEEmK 7tQ4CvbrRv+TfUAhFZmP7GeJtQRsq2SI6NMy/AzHYZowBGu08b7GNiH//9S5bDw4pMPi TJfuFsxr8Krf1Pqi2E3oi0xUcf4pw+jiSn4XZADhbrByTGAYwxjA6+plUWhaniTH/IS3 EyqLqyh+1nycGlIXrTn+hGEcXVL1oigOTb/itzFLcmmIlHUzVmNRJd67tgbaUxrHx7Vx HP9w== X-Gm-Message-State: AOAM532FeGefl+pEY+YeV43ojrjpcDNXR4qIhOaWAPyfpxlTm6meaoGq tHNwcQdWapxkRQm7tSZ2CeI= X-Google-Smtp-Source: ABdhPJzbTQvMZtXDyxVO8ULs7sEADU6xQe7jmnrOCwhUae5ucdkpIlQgqMYhXK22H9Y8+R2lqCWBFQ== X-Received: by 2002:a62:3381:0:b029:196:31a5:c2d4 with SMTP id z123-20020a6233810000b029019631a5c2d4mr19249675pfz.29.1605992691445; Sat, 21 Nov 2020 13:04:51 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:43c:d362:ed91:20bf:333c:1bc4]) by smtp.googlemail.com with ESMTPSA id 84sm7817851pfu.53.2020.11.21.13.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 13:04:50 -0800 (PST) From: Aditya Srivastava To: joe@perches.com Date: Sun, 22 Nov 2020 02:34:42 +0530 Message-Id: <20201121210442.17299-1-yashsri421@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, yashsri421@gmail.com Subject: [Linux-kernel-mentees] [PATCH v4] checkpatch: add fix option for LOGICAL_CONTINUATIONS X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" 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 adding logical operator at the end of previous line and removing from current line, if both the lines are additions (ie start with '+') Signed-off-by: Aditya Srivastava --- changes in v2: quote $operator at substitution changes in v3: add a check for previous line ending with comment; If so, insert $operator at the last non-comment, non-whitespace char of the previous line changes in v4: improve the matching mechanism by matching line termination at comment or white space; insert the operator before comments (if any) separated by a whitespace; append the comment and its pre-whitespace after the inserted operator (if comment was present), ie if no comment was present nothing will be inserted after the operator scripts/checkpatch.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5b1a5a65e69a..43a05519665d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3553,8 +3553,19 @@ 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 =~ /^\+/) { + # add logical operator to the previous line, remove from current line + # match line termination at comment or whitespace + if ($prevrawline =~ /(\s*(?:\/\/.*)*)$/) { + my $match = $1; + $fixed[$fixlinenr - 1] =~ s/$match//; + $fixed[$fixlinenr - 1] .= " $operator$match"; + } + $fixed[$fixlinenr] =~ s/\Q$operator\E\s*//; + } } # check indentation starts on a tab stop -- 2.17.1 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees