diff mbox

[v2] sparsec: simplify & portable use of mktemp

Message ID 20180616094724.82996-1-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Luc Van Oostenryck June 16, 2018, 9:47 a.m. UTC
Most manpages for mktemp(1) specify that the 'XXXXXX' part of the
template must be at the end (of course, the GNU's version accept
it anywhere). At least the busybox's version used by Alpine Linux
tries to enforce that and fails in sparse current use of it:
	tmp.XXXXXX.{llvm,o}

OTOH, the llc command can take its input from stdin and so there
is no need to have 2 temp files that need to be distinguished.

Fix the portability problem by feeding llc via stdin, which removes
the need for the first temp file, and using 'tmp.XXXXXX' as template
for the remaining one.

Fixes: a410611d7 "(llvm: fix creation of sparsec's tmp files")
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---

Changes since v1:
- remove the need to have 2 temp file by using a pipe instead.


 sparsec | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/sparsec b/sparsec
index e421776e2..fae49dab4 100755
--- a/sparsec
+++ b/sparsec
@@ -29,14 +29,12 @@  while [ $# -gt 0 ]; do
 	shift
 done
 
-TMPLLVM=`mktemp -t tmp.XXXXXX.llvm`
-TMPFILE=`mktemp -t tmp.XXXXXX.o`
+TMPFILE=`mktemp -t tmp.XXXXXX`
 
-$DIRNAME/sparse-llvm $SPARSEOPTS > $TMPLLVM
 
 LLC=`"${LLVM_CONFIG:-llvm-config}" --bindir`/llc
 
-$LLC -o - $TMPLLVM | as -o $TMPFILE
+$DIRNAME/sparse-llvm $SPARSEOPTS | $LLC | as -o $TMPFILE
 
 if [ $NEED_LINK -eq 1 ]; then
 	if [ -z $OUTFILE ]; then
@@ -50,5 +48,3 @@  else
 	fi
 	mv $TMPFILE $OUTFILE
 fi
-
-rm -f $TMPLLVM