summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/riff.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/riff.c b/src/riff.c
index 77def32..b59c819 100644
--- a/src/riff.c
+++ b/src/riff.c
@@ -78,10 +78,9 @@ static xas_riff *file_new(const char *path,
goto error_malloc_riff;
}
- riff->fd = (flags & O_CREAT)? open(path, flags, 0644):
- open(path, flags);
+ flags |= O_CREAT;
- if (riff->fd < 0) {
+ if ((riff->fd = open(path, flags, 0644)) < 0) {
goto error_open;
}
@@ -90,10 +89,8 @@ static xas_riff *file_new(const char *path,
riff->sample_rate = sample_rate;
riff->channels = channels;
- if (flags & (O_CREAT | O_TRUNC)) {
- if (header_write(riff) < 0) {
- goto error_header_write;
- }
+ if (header_write(riff) < 0) {
+ goto error_header_write;
}
return riff;