From owner-svn-src-head@freebsd.org Fri May 18 14:14:05 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87A46EA9762; Fri, 18 May 2018 14:14:05 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3D4C777C3E; Fri, 18 May 2018 14:14:05 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1EB9719373; Fri, 18 May 2018 14:14:05 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4IEE55s092667; Fri, 18 May 2018 14:14:05 GMT (envelope-from gallatin@FreeBSD.org) Received: (from gallatin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4IEE5YW092666; Fri, 18 May 2018 14:14:05 GMT (envelope-from gallatin@FreeBSD.org) Message-Id: <201805181414.w4IEE5YW092666@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gallatin set sender to gallatin@FreeBSD.org using -f From: Andrew Gallatin Date: Fri, 18 May 2018 14:14:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333793 - head/usr.sbin/pmcannotate X-SVN-Group: head X-SVN-Commit-Author: gallatin X-SVN-Commit-Paths: head/usr.sbin/pmcannotate X-SVN-Commit-Revision: 333793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 May 2018 14:14:05 -0000 Author: gallatin Date: Fri May 18 14:14:04 2018 New Revision: 333793 URL: https://svnweb.freebsd.org/changeset/base/333793 Log: Teach pmcannotate about $TMPDIR and _PATH_TMP Convert pmcannotate to using $TMPDIR and _PATH_TMP rather than hard coding /tmp for temporary files. Pmcannotate sometimes needs quite a lot of space to store the output from objdump, and will fail in odd ways if that output is truncated due to lack of space in /tmp. Reviewed by: jtl Sponsored by: Netflix Modified: head/usr.sbin/pmcannotate/pmcannotate.c Modified: head/usr.sbin/pmcannotate/pmcannotate.c ============================================================================== --- head/usr.sbin/pmcannotate/pmcannotate.c Fri May 18 13:49:12 2018 (r333792) +++ head/usr.sbin/pmcannotate/pmcannotate.c Fri May 18 14:14:04 2018 (r333793) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -47,7 +48,7 @@ __FBSDID("$FreeBSD$"); #define FNBUFF 512 #define LNBUFF 512 -#define TMPPATH "/tmp/pmcannotate.XXXXXX" +#define TMPNAME "pmcannotate.XXXXXX" #define FATAL(ptr, x ...) do { \ fqueue_deleteall(); \ @@ -671,7 +672,8 @@ usage(const char *progname) int main(int argc, char *argv[]) { - char buffer[LNBUFF], fname[FNBUFF], tbfl[] = TMPPATH, tofl[] = TMPPATH; + char buffer[LNBUFF], fname[FNBUFF]; + char *tbfl, *tofl, *tmpdir; char tmpf[MAXPATHLEN * 2 + 50]; float limit; char *bin, *exec, *kfile, *ofile; @@ -721,6 +723,17 @@ main(int argc, char *argv[]) exec); bzero(tmpf, sizeof(tmpf)); + tmpdir = getenv("TMPDIR"); + if (tmpdir == NULL) { + asprintf(&tbfl, "%s/%s", _PATH_TMP, TMPNAME); + asprintf(&tofl, "%s/%s", _PATH_TMP, TMPNAME); + } else { + asprintf(&tbfl, "%s/%s", tmpdir, TMPNAME); + asprintf(&tofl, "%s/%s", tmpdir, TMPNAME); + } + if (tofl == NULL || tbfl == NULL) + FATAL(exec, "%s: Cannot create tempfile templates\n", + exec); if (mkstemp(tofl) == -1) FATAL(exec, "%s: Impossible to create the tmp file\n", exec);