The result from pg_preadv() or pg_pwritev(), which is of type ssize_t,
is assigned to PgAioHandle.result, which is of type int. This should
be ok because the maximum result is limited by PG_IOV_MAX times
BLCKSZ. Add an assertion and a code comment to explain and check
this.
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://www.postgresql.org/message-id/flat/
f9aab072-0078-49e4-ab93-
3b08086a4406@eisentraut.org
elog(ERROR, "trying to execute invalid IO operation");
}
+ /*
+ * ssize_t to int conversion should be ok because result should be no more
+ * than PG_IOV_MAX times BLCKSZ.
+ */
+ Assert(result <= INT_MAX);
ioh->result = result < 0 ? -errno : result;
pgaio_io_process_completion(ioh, ioh->result);