commit - 276bccc4651afa03134d0faa1cf1c703b5f819bd
commit + 08ea2d1b208deaafa404f05069a578e4c58a9a6d
blob - 8badab72875c91358f1c37cf5df22ced9e96953a
blob + 044b02875ab1742a706a4d1967f1b02e2931d346
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
const struct got_error *
got_gotweb_flushfile(FILE *f)
{
+ const struct got_error *err = NULL;
+
if (fseek(f, 0, SEEK_SET) == -1)
- return got_error_from_errno("fseek");
+ err = got_error_from_errno("fseek");
- if (ftruncate(fileno(f), 0) == -1)
- return got_error_from_errno("ftruncate");
+ if (err == NULL && ftruncate(fileno(f), 0) == -1)
+ err = got_error_from_errno("ftruncate");
- if (fsync(fileno(f)) == -1)
- return got_error_from_errno("fsync");
+ if (err == NULL && fsync(fileno(f)) == -1)
+ err = got_error_from_errno("fsync");
- if (fclose(f) == EOF)
- return got_error_from_errno("fclose");
+ if (fclose(f) == EOF && err == NULL)
+ err = got_error_from_errno("fclose");
- return NULL;
+ return err;
}
static const struct got_error *