From patchwork Tue Oct 30 21:03:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 29967 Received: (qmail 96616 invoked by alias); 30 Oct 2018 21:04:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 95852 invoked by uid 89); 30 Oct 2018 21:04:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MIME_BASE64_BLANKS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=UD:pathstuff.c, pathstuff.c, pathstuffc X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 30 Oct 2018 21:03:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1540933425; x=1543525425; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=L3124Ra+T6eO0h6UczbitHKhM3OO4PVS40al1barWQ0=; b=Wf3I7495BZ//O7p78DMYUOZASrAHi36TlWlQk+S7FL8zJ5pKBLUvJ2RM1uWeOMYx Ery0wed3JbGQbCn25tGkWMGo3jqJ11Y1Q9CkEll5gM+m4tOfJB7bNNt95w22TGyQ 263bGAD4MPMCYi5PFDrF72PLaZM98jTKPECM4SidLiM=; Received: from ESESSMB503.ericsson.se (Unknown_Domain [153.88.183.121]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id E7.C4.17229.137C8DB5; Tue, 30 Oct 2018 22:03:45 +0100 (CET) Received: from ESESSMB502.ericsson.se (153.88.183.163) by ESESSMB503.ericsson.se (153.88.183.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 30 Oct 2018 22:03:45 +0100 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB502.ericsson.se (153.88.183.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Tue, 30 Oct 2018 22:03:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L3124Ra+T6eO0h6UczbitHKhM3OO4PVS40al1barWQ0=; b=R9zHAY2I/f/Uzl6SJ9oV0ytkSXequaw/qY1KK4fPMXCfhpk+YBos0/dW5jvfMQP7eEgB0su8qoLLgasSbiKeJL6cn+bNqmLjwQBou2+oq3+xNJ5Jd1YBFF1GNZ4uR4rZGU8WlPu+C3AWc6Q0+o+UQ0QkplI90+fGi6ki5iUDsDo= Received: from BYAPR15MB2390.namprd15.prod.outlook.com (52.135.198.30) by BYAPR15MB2231.namprd15.prod.outlook.com (52.135.196.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Tue, 30 Oct 2018 21:03:42 +0000 Received: from BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::649a:ddbf:ecc5:1f0a]) by BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::649a:ddbf:ecc5:1f0a%3]) with mapi id 15.20.1273.028; Tue, 30 Oct 2018 21:03:42 +0000 From: Simon Marchi To: Tom Tromey CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH v2 3/6] Move mkdir_recursive to common/filestuff.c Date: Tue, 30 Oct 2018 21:03:42 +0000 Message-ID: References: <20181018223100.20693-1-tom@tromey.com> <20181018223100.20693-4-tom@tromey.com> <6a239617-b748-0a9f-185b-2adcb19c50bc@ericsson.com> <87efc7nohb.fsf@tromey.com> In-Reply-To: <87efc7nohb.fsf@tromey.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) Content-ID: <2035C22DA39DBB469253512FA30FD2CC@namprd15.prod.outlook.com> MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com X-IsSubscribed: yes On 2018-10-30 4:55 p.m., Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi writes: > > Simon> What do you think about this? > > Thanks for doing this. > > Simon> /* See common/pathstuff.h. */ > > Simon> +std::string > Simon> +get_standard_temp_dir () > Simon> +{ > Simon> +#ifdef WIN32 > Simon> + char *tmp = getenv ("TMP"); > Simon> + if (tmp != nullptr) > Simon> + return tmp; > Simon> + > Simon> + tmp = getenv ("TEMP"); > Simon> + if (tmp != nullptr) > Simon> + return tmp; > Simon> + > Simon> + error (_("Couldn't find temp dir path, both TMP and TEMP are unset.")); > Simon> + > Simon> +#else > Simon> + return "/tmp"; > > It would be normal to look at TMPDIR on unix systems. Ah, indeed. How is it with this little fixup on top of the patch? From e8b9d0eabfb9bd85afcf42af9bdfb6a5bde66fc2 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 30 Oct 2018 17:01:50 -0400 Subject: [PATCH] fixup --- gdb/common/pathstuff.c | 4 ++++ gdb/common/pathstuff.h | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) -- 2.19.1 diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c index c0c575f3fb4..166a21593eb 100644 --- a/gdb/common/pathstuff.c +++ b/gdb/common/pathstuff.c @@ -208,6 +208,10 @@ get_standard_temp_dir () error (_("Couldn't find temp dir path, both TMP and TEMP are unset.")); #else + char *tmp = getenv ("TMPDIR"); + if (tmp != nullptr) + return tmp; + return "/tmp"; #endif } diff --git a/gdb/common/pathstuff.h b/gdb/common/pathstuff.h index 18af733ab98..f29349e8b28 100644 --- a/gdb/common/pathstuff.h +++ b/gdb/common/pathstuff.h @@ -68,8 +68,9 @@ extern std::string get_standard_cache_dir (); /* Get the usual temporary directory for the current platform. - On Windows, this is the TMP or TEMP environment variable. On the rest, - it's /tmp. + On Windows, this is the TMP or TEMP environment variable. + + On the rest, this is the TMPDIR environment variable, if defined, else /tmp. Throw an exception on error. */