You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/10/24 15:43:55 UTC

[GitHub] ccollins476ad closed pull request #1478: sim: Unlink temporary `native_flash.XXXXXX` files

ccollins476ad closed pull request #1478: sim: Unlink temporary `native_flash.XXXXXX` files
URL: https://github.com/apache/mynewt-core/pull/1478
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/mcu/native/src/hal_flash.c b/hw/mcu/native/src/hal_flash.c
index e3dde504ba..cdc36d5def 100644
--- a/hw/mcu/native/src/hal_flash.c
+++ b/hw/mcu/native/src/hal_flash.c
@@ -94,6 +94,8 @@ static void
 flash_native_file_open(char *name)
 {
     int created = 0;
+    char tmpl[] = "/tmp/native_flash.XXXXXX";
+
     extern int ftruncate(int fd, off_t length);
 
     if (name) {
@@ -104,7 +106,6 @@ flash_native_file_open(char *name)
             created = 1;
         }
     } else {
-        char tmpl[] = "/tmp/native_flash.XXXXXX";
         file = mkstemp(tmpl);
         assert(file > 0);
         created = 1;
@@ -122,6 +123,11 @@ flash_native_file_open(char *name)
     if (created) {
         flash_native_erase(0, native_flash_dev.hf_size);
     }
+
+    /* If using a temporary file, unlink it immediately. */
+    if (name == NULL) {
+        remove(tmpl);
+    }
 }
 
 static void


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services