Mercurial > hg > audiodb
diff dump.cpp @ 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 | a8a5f2ca5380 |
children | 62a0515f59be |
line wrap: on
line diff
--- a/dump.cpp Tue Dec 09 22:48:30 2008 +0000 +++ b/dump.cpp Thu Dec 11 08:54:01 2008 +0000 @@ -135,9 +135,7 @@ if ((ffd = open(fName, O_CREAT|O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { goto error; } - if ((write(ffd, &(adb->header->dim), sizeof(uint32_t))) < 0) { - goto error; - } + write_or_goto_error(ffd, &(adb->header->dim), sizeof(uint32_t)); /* FIXME: this repeated malloc()/free() of data buffers is inefficient. */ @@ -155,9 +153,7 @@ goto error; } - if ((write(ffd, data_buffer, data_buffer_size)) < 0) { - goto error; - } + write_or_goto_error(ffd, data_buffer, data_buffer_size); free(data_buffer); @@ -189,12 +185,8 @@ if ((pfd = open(fName, O_CREAT|O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { goto error; } - if ((write(pfd, &one, sizeof(uint32_t))) < 0) { - goto error; - } - if ((write(pfd, powerTable + pos, trackTable[k] * sizeof(double))) < 0) { - goto error; - } + write_or_goto_error(pfd, &one, sizeof(uint32_t)); + write_or_goto_error(pfd, powerTable + pos, trackTable[k] * sizeof(double)); fprintf(pLFile, "%s\n", fName); close(pfd); pfd = 0; @@ -294,7 +286,8 @@ maybe_munmap(powerFileNameTable, fileTableLength); if(directory_changed) { - chdir(cwd); + int gcc_warning_workaround = chdir(cwd); + directory_changed = gcc_warning_workaround; } return 1; }