Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2672812pxu; Sun, 29 Nov 2020 00:58:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+e9wulzR3awbHmx7SctqTQ69+XdLJrhuDTfT75yiOCdzE6W0ofWxYZU/9OLX79CPQ4wJu X-Received: by 2002:aa7:c5d0:: with SMTP id h16mr15989251eds.381.1606640304713; Sun, 29 Nov 2020 00:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606640304; cv=none; d=google.com; s=arc-20160816; b=eelSLVFepOPWNrGiLPgY8cRu1h7EKp1lHW57FpANoMOofMjwQmLRwRBrjuApG4lWew koh49JXSOC4vHDFODUDdNQBIux8yZGWqJQxy/ZlZL8iEHoQtaZKckF3EJh9PqzJv/Qyk jjrGMc2jh3sMzyDzGVMHwOkpyg8eSv/qw+z3E8duJHeYTZlq2h+VxuMRbCbtVWfTN5Yw dIbDsVfesSjN3HyXcptA+T+G2QB8vzMNmWMhDoVX60uBQ/OYCKjGFWoLfxkMyeveEQQ2 GmNYNgag6dCFqPGiFbDLmEgAN4YfSuniZXCziVAqcVlR5eQvzrgtkD6fCLnoW7f4VoX+ O66w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=asdqBoIk1ZdzjfqdX/jQ+vQPjLAQMqzWC0xNbHtbH/M=; b=B+3C/CeSI4YW293JX23qqQtYUVtqvyiail8pTNL8xm98680j2GQcNrfwmZQREBsZMW icnRrLbvp85HFi+ZHAb1qBef7B1mgaFu+nURr1Ou7972RjrXR1dd4ZxsO8qtH1y+AWgJ geCSOzL2Zg/6rRkJjCImCUA4FecpAktenCPbHhjNNV4+ZBVpidOz2CzJorgpFlR2HBNJ wyWIwf0enV1F6v5SOyvJmMM3WLyYDTt6+noGWLZN+b67xmc9rHIiQaDweY7f9NiBTQxO ELaeDYZTKiotcI8qhSuu//b4vwWz6hOGNkZ3kxUWFyu74MC8B5Q9VrP6s/f1AidsFLde YZDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RG7aCMZC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si6539366eji.561.2020.11.29.00.58.02; Sun, 29 Nov 2020 00:58:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RG7aCMZC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726136AbgK2I4D (ORCPT + 99 others); Sun, 29 Nov 2020 03:56:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbgK2I4D (ORCPT ); Sun, 29 Nov 2020 03:56:03 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3325BC0613D1 for ; Sun, 29 Nov 2020 00:55:17 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id o4so5634627pgj.0 for ; Sun, 29 Nov 2020 00:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=asdqBoIk1ZdzjfqdX/jQ+vQPjLAQMqzWC0xNbHtbH/M=; b=RG7aCMZCbbpDxaV4pWpEo01Q/1oq0fy8d7t/whwLwnwkmEhpEcXuZHhE086oRR/+do bl3+Hl1jjuqKGCLXqxAxaKtxOiIP4+A9dZ2vsTJsNxX2BPHVkVgLVYVj0jb2vexkCId+ x5xQmuOCddJe9NVF+ITdnVofNmSwbhhhookzEIuGeiw2dXzfoTEVVQYWca+FaCQDX8AN Nby53fbLjf1c8ZiWewkVPhqgYUDWvZIF6eiVBIBi++bb1MyF4Qh++8hICTkS3mbqXFXQ 9/CpOPZm510m89YQB/fVyFCiuOhj4ykbYxkW5fkrTd3kcxb3adMJP3bcTlXO1eyTtNGR BwjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=asdqBoIk1ZdzjfqdX/jQ+vQPjLAQMqzWC0xNbHtbH/M=; b=PR+NKOrusSbjMLmVqWNUO8vTx2hGVLAJYafhRjX9jcfn2kQK27JNrGGQvzIPhQya5j BP0V2X1RQeIqHSYOCsESsxH3vRzhEdl/FYNjwdOVELJfnGc7afe1VX5vg6UJKEG5kWqh cluZ9+Fvgc+IqKIU0GsxrRrjvgV5aEXsgLUzfNA+akbjQ4bkg4UxoMg1QmIxcNq4xqen 6aJmBRxyyXZu86ccqyYv3rHQoZd9yQjZ6fqYc9ThgUfSTD5KBXwhKXhTBGU28NX5qdiZ Ft53pQGEs19/ussmhpzI521MD0LMenT3w73lGVMXbOUH1REIhZGIDtXj1qLrXfJiFt5m QvpQ== X-Gm-Message-State: AOAM531A90B1TIwY2ttYxnKJdaSBsoZRU7OOUuqQmSRW+uRjodkNsKIJ pvJWlb9GLk5BVtKT6V9RKnl6xziljQYULw== X-Received: by 2002:a17:90a:2b0b:: with SMTP id x11mr20233613pjc.65.1606640116459; Sun, 29 Nov 2020 00:55:16 -0800 (PST) Received: from ?IPv6:2402:3a80:43d:11a0:15a2:ad13:ec3b:4e56? ([2402:3a80:43d:11a0:15a2:ad13:ec3b:4e56]) by smtp.gmail.com with ESMTPSA id h4sm11513617pgp.8.2020.11.29.00.55.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2020 00:55:15 -0800 (PST) Subject: Re: [PATCH v7] checkpatch: add fix option for LOGICAL_CONTINUATIONS To: joe@perches.com Cc: lukas.bulwahn@gmail.com, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org References: <20201123102818.24364-1-yashsri421@gmail.com> From: Aditya Message-ID: Date: Sun, 29 Nov 2020 14:25:09 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201123102818.24364-1-yashsri421@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/11/20 3:58 pm, Aditya Srivastava wrote: > 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 '+') > > 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 > > changes in v5: improve regex for comment and line end with '$;' > > changes in v6: remove if-check; modify commit message > > changes in v7: add an extra '$' symbol at '$fixed[$fixlinenr - 1]' regex substitution to ensure match at line end > > scripts/checkpatch.pl | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 5b1a5a65e69a..fb3c50e0bde2 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -3553,8 +3553,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 > Hi Joe You probably missed this patch. Please review :) Thanks Aditya