aboutsummaryrefslogtreecommitdiff
path: root/scripts/decodecode
diff options
context:
space:
mode:
authorRandy Dunlap <randy.dunlap@oracle.com>2008-01-14 15:18:31 -0800
committerSam Ravnborg <sam@ravnborg.org>2008-01-28 23:14:40 +0100
commitfa220d89ad050cf5d970c0418ded019a80efedfb (patch)
tree6148ecb571839fbc253582f86d4c7f9161b1e7d7 /scripts/decodecode
parent80daa56008dad44f08d0b47670cf2513aa98ab53 (diff)
downloadvexpress-lsk-fa220d89ad050cf5d970c0418ded019a80efedfb.tar.gz
kbuild: minor scripts/decodecode update
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> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/decodecode')
-rw-r--r--scripts/decodecode17
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/decodecode b/scripts/decodecode
index 1e1a8f620c4..235d3938529 100644
--- a/scripts/decodecode
+++ b/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