mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts: minor decodecode update
@ 2008-01-14 23:18 Randy Dunlap
  2008-01-16 21:30 ` Sam Ravnborg
  0 siblings, 1 reply; 2+ messages in thread
From: Randy Dunlap @ 2008-01-14 23:18 UTC (permalink / raw)
  To: lkml; +Cc: akpm, samr

From: Randy Dunlap <randy.dunlap@oracle.com>

Remove the tmp file when exiting.  Noticed by Arjan van de Ven.
Catch mktemp failure and exit with message.
Trap kill or other signals and exit cleanly.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 scripts/decodecode |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

--- linux-2.6.24-rc7.orig/scripts/decodecode
+++ linux-2.6.24-rc7/scripts/decodecode
@@ -6,7 +6,19 @@
 # e.g., to decode an i386 oops on an x86_64 system, use:
 # AFLAGS=--32 decodecode < 386.oops
 
-T=`mktemp`
+cleanup() {
+	rm -f $T $T.s $T.o
+	exit 1
+}
+
+die() {
+	echo "$@"
+	exit 1
+}
+
+trap cleanup EXIT
+
+T=`mktemp` || die "cannot create temp file"
 code=
 
 while read i ; do
@@ -20,6 +32,7 @@ esac
 done
 
 if [ -z "$code" ]; then
+	rm $T
 	exit
 fi
 
@@ -48,4 +61,4 @@ echo -n "	.byte 0x" > $T.s
 echo $code >> $T.s
 as $AFLAGS -o $T.o $T.s
 objdump -S $T.o
-rm $T.o $T.s
+rm $T $T.s $T.o

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts: minor decodecode update
  2008-01-14 23:18 [PATCH] scripts: minor decodecode update Randy Dunlap
@ 2008-01-16 21:30 ` Sam Ravnborg
  0 siblings, 0 replies; 2+ messages in thread
From: Sam Ravnborg @ 2008-01-16 21:30 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: lkml, akpm

On Mon, Jan 14, 2008 at 03:18:31PM -0800, Randy Dunlap wrote:
> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> Remove the tmp file when exiting.  Noticed by Arjan van de Ven.
> Catch mktemp failure and exit with message.
> Trap kill or other signals and exit cleanly.

Applied,

	Sam

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-16 21:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-14 23:18 [PATCH] scripts: minor decodecode update Randy Dunlap
2008-01-16 21:30 ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®