Skip to content

Commit df10ac6

Browse files
committed
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
1 parent ee1b38f commit df10ac6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/port/pwrite.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
7070
return -1;
7171
return writev(fd, iov, iovcnt);
7272
#else
73-
ssize_t sum = 0;
74-
ssize_t part;
73+
ssize_t sum = 0;
74+
ssize_t part;
7575

7676
for (int i = 0; i < iovcnt; ++i)
7777
{
@@ -137,14 +137,14 @@ pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset)
137137
/* Are they all done? */
138138
if (iovcnt == 0)
139139
{
140-
if (part > 0)
141-
elog(ERROR, "unexpectedly wrote more than requested");
140+
/* We don't expect the kernel to write more than requested. */
141+
Assert(part == 0);
142142
break;
143143
}
144144

145145
/*
146-
* Move whatever's left to the front of our mutable copy and adjust the
147-
* leading iovec.
146+
* Move whatever's left to the front of our mutable copy and adjust
147+
* the leading iovec.
148148
*/
149149
Assert(iovcnt > 0);
150150
memmove(iov_copy, iov, sizeof(*iov) * iovcnt);

0 commit comments

Comments
 (0)