aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2021-01-13 19:11:09 +1300
committerThomas Munro <tmunro@postgresql.org>2021-01-13 19:34:14 +1300
commitdf10ac625c1672edf839ff59cfcac9dcc097515c (patch)
treeedd966c9600c57a5bcf81f8e2e8d4cbd9a8f084c /src
parentee1b38f65948cb09ecf3c39b58bd88aabc950e7c (diff)
downloadpostgresql-df10ac625c1672edf839ff59cfcac9dcc097515c.tar.gz
postgresql-df10ac625c1672edf839ff59cfcac9dcc097515c.zip
Don't use elog() in src/port/pwrite.c.
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
Diffstat (limited to 'src')
-rw-r--r--src/port/pwrite.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/port/pwrite.c b/src/port/pwrite.c
index e029f44bc0c..a98343ec05b 100644
--- a/src/port/pwrite.c
+++ b/src/port/pwrite.c
@@ -70,8 +70,8 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
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)
{
@@ -137,14 +137,14 @@ pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset)
/* 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);