char *buf = new char[write_size];
memset(static_cast<void*>(buf), 0, write_size);
uint64_t i = 0;
- for (; (i + write_size) <= (unsigned)max_size; i += write_size)
- ::pwrite(fd, static_cast<void*>(buf), write_size, i);
- if (i < (unsigned)max_size)
- ::pwrite(fd, static_cast<void*>(buf), max_size - i, i);
+ for (; (i + write_size) <= (unsigned)max_size; i += write_size) {
+ ret = ::pwrite(fd, static_cast<void*>(buf), write_size, i);
+ if (ret < 0)
+ return -errno;
+ }
+ if (i < (unsigned)max_size) {
+ ret = ::pwrite(fd, static_cast<void*>(buf), max_size - i, i);
+ if (ret < 0)
+ return -errno;
+ }
delete [] buf;
}