Mercurial > blahgd > experimental
changeset 738:ce22627e67da
utils: write_file() should return 0 or positive errno
Also fix up comment code that was relying on write_file() leaving errno set
to a useful value.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Tue, 13 Oct 2015 13:43:48 -0400 |
parents | 488bc117d9a9 |
children | 5c14be61e43a |
files | comment.c utils.c |
diffstat | 2 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/comment.c Tue Oct 13 13:41:22 2015 -0400 +++ b/comment.c Tue Oct 13 13:43:48 2015 -0400 @@ -199,7 +199,7 @@ ret = write_file(textpath, comment, strlen(comment)); if (ret) { LOG("Couldn't write file ... :( %d (%s) '%s'", - errno, strerror(errno), textpath); + ret, strerror(ret), textpath); return INTERNAL_ERR; } @@ -217,7 +217,7 @@ if (ret) { LOG("Couldn't write file ... :( %d (%s) '%s'", - errno, strerror(errno), lisppath); + ret, strerror(ret), lisppath); return INTERNAL_ERR; }
--- a/utils.c Tue Oct 13 13:41:22 2015 -0400 +++ b/utils.c Tue Oct 13 13:43:48 2015 -0400 @@ -172,15 +172,14 @@ fd = open(fname, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (fd == -1) - return 1; + return errno; ret = xwrite(fd, data, len); close(fd); - return ret != 0; + return ret; } #define NARGS 5