Nothing broke because of this oversight yet, but it would fail to link
if we tried to use pg_pwrite() in frontend code on a system that lacks
pwrite(). Use an assertion instead. Also pgindent while here.
Discussion: https://postgr.es/m/CA%2BhUKGL57RvoQsS35TVPnQoPYqbtBixsdRhynB8NpcUKpHTTtg%40mail.gmail.com
return -1;
return writev(fd, iov, iovcnt);
#else
- ssize_t sum = 0;
- ssize_t part;
+ ssize_t sum = 0;
+ ssize_t part;
for (int i = 0; i < iovcnt; ++i)
{
/* Are they all done? */
if (iovcnt == 0)
{
- if (part > 0)
- elog(ERROR, "unexpectedly wrote more than requested");
+ /* We don't expect the kernel to write more than requested. */
+ Assert(part == 0);
break;
}
/*
- * Move whatever's left to the front of our mutable copy and adjust the
- * leading iovec.
+ * Move whatever's left to the front of our mutable copy and adjust
+ * the leading iovec.
*/
Assert(iovcnt > 0);
memmove(iov_copy, iov, sizeof(*iov) * iovcnt);