Mercurial > hg > audiodb
diff audioDB-internals.h @ 410:d7e590d58c85 api-inversion
Pavlovian response to compiler warnings...
... attempt to squash them. For now we can get most of the way by
writing a simple write_or_goto_error() macro for write(), and the
equivalent for read().
One of the warnings, for the return value of chdir(), is silly, because
we're already in an error case, and we really can't do anything sensible
if the chdir fails. Try to deal with it anyway.
author | mas01cr |
---|---|
date | Thu, 11 Dec 2008 08:54:01 +0000 |
parents | f0a69693eaef |
children | 6e6f4c1cc14d |
line wrap: on
line diff
--- a/audioDB-internals.h Tue Dec 09 22:48:30 2008 +0000 +++ b/audioDB-internals.h Thu Dec 11 08:54:01 2008 +0000 @@ -32,6 +32,20 @@ } \ } +#define write_or_goto_error(fd, buffer, size) \ + { ssize_t tmp = size; \ + if(write(fd, buffer, size) != tmp) { \ + goto error; \ + } \ + } + +#define read_or_goto_error(fd, buffer, size) \ + { ssize_t tmp = size; \ + if(read(fd, buffer, size) != tmp) { \ + goto error; \ + } \ + } + static inline int audiodb_sync_header(adb_t *adb) { off_t pos; pos = lseek(adb->fd, (off_t) 0, SEEK_CUR);