]> git.sur5r.net Git - u-boot/blobdiff - arch/sandbox/cpu/state.c
Merge branch 'master' of git://git.denx.de/u-boot-spi
[u-boot] / arch / sandbox / cpu / state.c
index a145808a52d43c350b7b568d9678fe102bf4d662..ba73b7e251040831f45a38d29132479b605c0abc 100644 (file)
@@ -49,14 +49,14 @@ static int state_ensure_space(int extra_size)
 
 static int state_read_file(struct sandbox_state *state, const char *fname)
 {
-       int size;
+       loff_t size;
        int ret;
        int fd;
 
-       size = os_get_filesize(fname);
-       if (size < 0) {
+       ret = os_get_filesize(fname, &size);
+       if (ret < 0) {
                printf("Cannot find sandbox state file '%s'\n", fname);
-               return -ENOENT;
+               return ret;
        }
        state->state_fdt = os_malloc(size);
        if (!state->state_fdt) {
@@ -365,7 +365,7 @@ int state_uninit(void)
 
        state = &main_state;
 
-       if (state->write_ram_buf) {
+       if (state->write_ram_buf && !state->ram_buf_rm) {
                err = os_write_ram_buf(state->ram_buf_fname);
                if (err) {
                        printf("Failed to write RAM buffer\n");
@@ -380,6 +380,10 @@ int state_uninit(void)
                }
        }
 
+       /* Delete this at the last moment so as not to upset gdb too much */
+       if (state->jumped_fname)
+               os_unlink(state->jumped_fname);
+
        if (state->state_fdt)
                os_free(state->state_fdt);
        memset(state, '\0', sizeof(*state));