You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2019/03/21 14:47:22 UTC
[mynewt-core] branch master updated: mcu/native: Write flash files
to macOS TMPDIR
This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 16b88cc mcu/native: Write flash files to macOS TMPDIR
16b88cc is described below
commit 16b88cce02b69d538451600117f7013b2990fe82
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Wed Mar 20 22:26:41 2019 -0700
mcu/native: Write flash files to macOS TMPDIR
This is an experimental fix for a recurring failure in some macOS travis
tests. In these tests, `mkstemp()` fails when a template starting with
`/tmp` is used.
This experiment is to use `$TMPDIR` instead of `/tmp`, if `$TMPDIR` is
set (i.e., if this is macOS).
---
hw/mcu/native/src/hal_flash.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/mcu/native/src/hal_flash.c b/hw/mcu/native/src/hal_flash.c
index df200c2..24770e1 100644
--- a/hw/mcu/native/src/hal_flash.c
+++ b/hw/mcu/native/src/hal_flash.c
@@ -94,10 +94,19 @@ static void
flash_native_file_open(char *name)
{
int created = 0;
- char tmpl[] = "/tmp/native_flash.XXXXXX";
+ char tmpl[256];
+ const char *tmpdir;
extern int ftruncate(int fd, off_t length);
+ /* Attempt to use the current macOS user's temporary directory. */
+ tmpdir = getenv("TMPDIR");
+ if (tmpdir == NULL) {
+ tmpdir = "/tmp";
+ }
+
+ snprintf(tmpl, sizeof tmpl, "%s/native_flash.XXXXXX", tmpdir);
+
if (name) {
file = open(name, O_RDWR);
if (file < 0) {