diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/bareboximd.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/scripts/bareboximd.c b/scripts/bareboximd.c index d11b661fa3..48c3e8ab3f 100644 --- a/scripts/bareboximd.c +++ b/scripts/bareboximd.c @@ -53,7 +53,7 @@ int imd_command_setenv(const char *variable_name, const char *value) static int write_file(const char *filename, const void *buf, size_t size) { - int fd; + int fd, ret = 0; int now; fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); @@ -62,19 +62,18 @@ static int write_file(const char *filename, const void *buf, size_t size) while (size) { now = write(fd, buf, size); - if (now == 0) { - errno = ENOSPC; - return -1; + if (now < 0) { + ret = now; + goto out; } - if (now < 0) - return now; size -= now; buf += now; } +out: close(fd); - return 0; + return ret; } static int read_file_2(const char *filename, size_t *size, void **outbuf, size_t max_size) |