From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id EE5D3A0471
	for <public@inbox.dpdk.org>; Tue, 13 Aug 2019 08:38:36 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 9D7E41BDAE;
	Tue, 13 Aug 2019 08:38:35 +0200 (CEST)
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
 by dpdk.org (Postfix) with ESMTP id 2651C8F96;
 Tue, 13 Aug 2019 08:38:34 +0200 (CEST)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
 [10.5.11.13])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mx1.redhat.com (Postfix) with ESMTPS id 58F94C028320;
 Tue, 13 Aug 2019 06:38:33 +0000 (UTC)
Received: from dmarchan.remote.csb (ovpn-204-32.brq.redhat.com [10.40.204.32])
 by smtp.corp.redhat.com (Postfix) with ESMTP id CE1D47BE6C;
 Tue, 13 Aug 2019 06:38:31 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net,
	stable@dpdk.org
Date: Tue, 13 Aug 2019 08:38:22 +0200
Message-Id: <1565678302-20294-1-git-send-email-david.marchand@redhat.com>
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
 (mx1.redhat.com [10.5.110.31]); Tue, 13 Aug 2019 06:38:33 +0000 (UTC)
Subject: [dpdk-dev] [PATCH] devtools: fix cleanup of temp file
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

The regexp part of the cleanup routine was not updated accordingly when
a common prefix for temp files was introduced.
Set the trap handler only when required.

Fixes: ff37ca5d3773 ("devtools: use a common prefix for temporary files")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 devtools/checkpatches.sh | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 8e2beee..b16bace 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -36,14 +36,6 @@ LINE_SPACING,PARENTHESIS_ALIGNMENT,NETWORKING_BLOCK_COMMENT_STYLE,\
 NEW_TYPEDEFS,COMPARISON_TO_NULL"
 options="$options $DPDK_CHECKPATCH_OPTIONS"
 
-clean_tmp_files() {
-	if echo $tmpinput | grep -q '^checkpatches\.' ; then
-		rm -f "$tmpinput"
-	fi
-}
-
-trap "clean_tmp_files" INT
-
 print_usage () {
 	cat <<- END_OF_HELP
 	usage: $(basename $0) [-q] [-v] [-nX|-r range|patch1 [patch2] ...]]
@@ -150,13 +142,16 @@ check () { # <patch> <commit> <title>
 	! $verbose || print_headline "$3"
 	if [ -n "$1" ] ; then
 		tmpinput=$1
-	elif [ -n "$2" ] ; then
-		tmpinput=$(mktemp -t dpdk.checkpatches.XXXXXX)
-		git format-patch --find-renames \
-		--no-stat --stdout -1 $commit > "$tmpinput"
 	else
 		tmpinput=$(mktemp -t dpdk.checkpatches.XXXXXX)
-		cat > "$tmpinput"
+		trap "rm -f '$tmpinput'" INT
+
+		if [ -n "$2" ] ; then
+			git format-patch --find-renames \
+			--no-stat --stdout -1 $commit > "$tmpinput"
+		else
+			cat > "$tmpinput"
+		fi
 	fi
 
 	! $verbose || printf 'Running checkpatch.pl:\n'
@@ -191,7 +186,10 @@ check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
-	clean_tmp_files
+	if [ "$tmpinput" != "$1" ]; then
+		rm -f "$tmpinput"
+		trap - INT
+	fi
 	[ $ret -eq 0 ] && return 0
 
 	status=$(($status + 1))
-- 
1.8.3.1