commit - 54ca6e2b432edddabc0fca60a74968e6ef4bf790
commit + 985ec13bc7dc1bc1885d8111e51ea98c619d0d4e
blob - bdf8758fa058df136c03a8194b95e48dabef8ede
blob + c4a36be92dece1c2aefe0758c42d4da768abf4fa
--- 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 *