devtools: fix cleanup of temp file
diff mbox series

Message ID 1565678302-20294-1-git-send-email-david.marchand@redhat.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • devtools: fix cleanup of temp file
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing fail Performance Testing issues
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

David Marchand Aug. 13, 2019, 6:38 a.m. UTC
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(-)

Comments

Thomas Monjalon Oct. 21, 2019, 2:12 p.m. UTC | #1
13/08/2019 08:38, David Marchand:
> 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>

Applied, my tmp folder says thanks
David Marchand Oct. 21, 2019, 6:54 p.m. UTC | #2
On Mon, Oct 21, 2019 at 4:12 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 13/08/2019 08:38, David Marchand:
> > 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>
>
> Applied, my tmp folder says thanks

Mine too :-)


--
David Marchand

Patch
diff mbox series

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))