From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 028BBA00C5 for ; Thu, 29 Sep 2022 14:04:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F068D427EC; Thu, 29 Sep 2022 14:04:58 +0200 (CEST) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by mails.dpdk.org (Postfix) with ESMTP id 623E740395 for ; Thu, 29 Sep 2022 14:04:57 +0200 (CEST) Received: by mail-wr1-f54.google.com with SMTP id r6so1838080wru.8 for ; Thu, 29 Sep 2022 05:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=kmCLWOeCX4eUKQgs0m7qdca0LfbjZJH4px/PD+l1so4=; b=anE98cHDLS2iriULAAwuSid+fs62Vu9eE3Vct4bUYMjQGv3C8N8QyLdKJlNUXgyUMG SMMKkyFaxxM9zfTmPXuXopIPLxvOsMLL49CC2diSxri6ZtQXELS+B+OjrvLaLrUPhqNq f6/Hkl6UDNXevOw0ONL/bSmPBvakch+wH7EtppBMdIPOjXERePFvuGFbCQdbn6YixZeR zC+pEYPhrpZHAfWZlnUWANoyP/eu1tsXe77iNjfs35QSgDoCcW67jrB1/mBltBjI7gR9 HpDYl2WvsL9Y3CS8dYPW9WHWkhzLP0kYlQO4uV1yTOg/ntk2sX/YQs/1U9rhZKQlj4GG xUaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=kmCLWOeCX4eUKQgs0m7qdca0LfbjZJH4px/PD+l1so4=; b=SmfS+u8i5gZyYCehrJqUvEIYhLF8fUaoOTFLl+gKTuFJ7xVwRuhEMSG42ButdCKjVo kbhhZ4d6rFTZrT6W3Anq1TzOqu3/hNsGxJ5sBNM0+85MUwrJPwyhD3tdzWoM8wm0h3Dd sgcivUYuaJoLFA9Rx37Ju0n6hVNdeFxTfqYULKSIqcXBpJ90EW24pZY6zbg6HERFpDZC 9QfmfCkcbNl/xklSdzriwQp2rxiNqwCRN54iM8c/ylvVngsmMX3cBhmP/QZDhx/8GPNM D9Pq2PDtuvVGDY1sh10QowdArPV4mreuRY09Kqc5DHqZ/xJ+Lzb+xRk8GMv0UvMZ7kIh T7aA== X-Gm-Message-State: ACrzQf3zAZpWH0m7fJGCSMjBCaWB4HppVkkXuJ7o00biNjox/llN2Go/ eDZTy4FVtQaqlZTanFpAefkS9Udo5gFM2PnR X-Google-Smtp-Source: AMsMyM4IJWov6RZ56g0ehqmdyKNNwYt74Tnu0BkeVw1yAWMd9XfaLJlBRSzUAEL7sUO3DcTz4tQQeg== X-Received: by 2002:a5d:504a:0:b0:228:a1ae:2038 with SMTP id h10-20020a5d504a000000b00228a1ae2038mr2023635wrt.645.1664453097053; Thu, 29 Sep 2022 05:04:57 -0700 (PDT) Received: from gojira.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id l18-20020a05600c1d1200b003a601a1c2f7sm4448251wms.19.2022.09.29.05.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 05:04:56 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Thomas Monjalon , stable@dpdk.org Subject: [PATCH] devtools: fix checkpatches subject retrieval from stdin Date: Thu, 29 Sep 2022 14:04:03 +0200 Message-Id: <20220929120403.352-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org When passing the patch to checkpatches.sh through stdin, the subject is retrieved by reading the input until a "Subject:" entry is found. The rest of the input is piped to checkpatch.pl. Since the "From:" line is before the "Subject:" line, it won't be sent to checkpatch.pl, which won't be able to get the author of the commit. The following error will appear: > ERROR:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author '' Do the subject lookup on the temporary file instead of stdin, and send the whole lines to checkpatch.pl. The problem is visible since the introduction of this check in linux checkpatch.pl in version 4.19 (see link below). Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cd2614967d8b Fixes: 8005feef421d ("scripts: add standard input to checkpatch") CC: stable@dpdk.org Signed-off-by: Olivier Matz --- devtools/checkpatches.sh | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index 0e82c01947..2b7005dfac 100755 --- a/devtools/checkpatches.sh +++ b/devtools/checkpatches.sh @@ -278,12 +278,12 @@ print_headline() { # total=0 status=0 -check () { # <patch> <commit> <title> +check () { # <patch-file> <commit> local ret=0 + local subject='' headline_printed=false total=$(($total + 1)) - ! $verbose || print_headline "$3" if [ -n "$1" ] ; then tmpinput=$1 else @@ -298,10 +298,14 @@ check () { # <patch> <commit> <title> fi fi + # Subject can be on 2 lines + subject=$(sed '/^Subject: */!d;s///;N;s,\n[[:space:]]\+, ,;s,\n.*,,;q' "$tmpinput") + ! $verbose || print_headline "$subject" + ! $verbose || printf 'Running checkpatch.pl:\n' report=$($DPDK_CHECKPATCH_PATH $options "$tmpinput" 2>/dev/null) if [ $? -ne 0 ] ; then - $headline_printed || print_headline "$3" + $headline_printed || print_headline "$subject" printf '%s\n' "$report" | sed -n '1,/^total:.*lines checked$/p' ret=1 fi @@ -309,7 +313,7 @@ check () { # <patch> <commit> <title> ! $verbose || printf '\nChecking API additions/removals:\n' report=$($VALIDATE_NEW_API "$tmpinput") if [ $? -ne 0 ] ; then - $headline_printed || print_headline "$3" + $headline_printed || print_headline "$subject" printf '%s\n' "$report" ret=1 fi @@ -317,7 +321,7 @@ check () { # <patch> <commit> <title> ! $verbose || printf '\nChecking forbidden tokens additions:\n' report=$(check_forbidden_additions "$tmpinput") if [ $? -ne 0 ] ; then - $headline_printed || print_headline "$3" + $headline_printed || print_headline "$subject" printf '%s\n' "$report" ret=1 fi @@ -325,7 +329,7 @@ check () { # <patch> <commit> <title> ! $verbose || printf '\nChecking __rte_experimental tags:\n' report=$(check_experimental_tags "$tmpinput") if [ $? -ne 0 ] ; then - $headline_printed || print_headline "$3" + $headline_printed || print_headline "$subject" printf '%s\n' "$report" ret=1 fi @@ -333,7 +337,7 @@ check () { # <patch> <commit> <title> ! $verbose || printf '\nChecking __rte_internal tags:\n' report=$(check_internal_tags "$tmpinput") if [ $? -ne 0 ] ; then - $headline_printed || print_headline "$3" + $headline_printed || print_headline "$subject" printf '%s\n' "$report" ret=1 fi @@ -341,7 +345,7 @@ check () { # <patch> <commit> <title> ! $verbose || printf '\nChecking release notes updates:\n' report=$(check_release_notes "$tmpinput") if [ $? -ne 0 ] ; then - $headline_printed || print_headline "$3" + $headline_printed || print_headline "$subject" printf '%s\n' "$report" ret=1 fi @@ -357,20 +361,10 @@ check () { # <patch> <commit> <title> if [ -n "$1" ] ; then for patch in "$@" ; do - # Subject can be on 2 lines - subject=$(sed '/^Subject: */!d;s///;N;s,\n[[:space:]]\+, ,;s,\n.*,,;q' "$patch") - check "$patch" '' "$subject" + check "$patch" '' done elif [ ! -t 0 ] ; then # stdin - subject=$(while read header value ; do - if [ "$header" = 'Subject:' ] ; then - IFS= read next - continuation=$(echo "$next" | sed -n 's,^[[:space:]]\+, ,p') - echo $value$continuation - break - fi - done) - check '' '' "$subject" + check '' '' else if [ $number -eq 0 ] ; then commits=$(git rev-list --reverse $range) @@ -378,8 +372,7 @@ else commits=$(git rev-list --reverse --max-count=$number HEAD) fi for commit in $commits ; do - subject=$(git log --format='%s' -1 $commit) - check '' $commit "$subject" + check '' $commit done fi pass=$(($total - $status)) -- 2.30.2