Skip to content

Commit 0a883a0

Browse files
Fix sign-compare warnings in pg_iovec.h.
The code in question (pg_preadv() and pg_pwritev()) has been around for a while, but commit 15c9ac3 moved it to a header file. If third-party code that includes this header file is built with -Wsign-compare on a system without preadv() or pwritev(), warnings ensue. This commit fixes said warnings by casting the result of pg_pread()/pg_pwrite() to size_t, which should be safe because we will have already checked for a negative value. Author: Wolfgang Walther Discussion: https://postgr.es/m/16989737-1aa8-48fd-8dfe-b7ada06509ab%40technowledgy.de Backpatch-through: 17
1 parent 4145ea0 commit 0a883a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/include/port/pg_iovec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
6868
}
6969
sum += part;
7070
offset += part;
71-
if (part < iov[i].iov_len)
71+
if ((size_t) part < iov[i].iov_len)
7272
return sum;
7373
}
7474
return sum;
@@ -107,7 +107,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
107107
}
108108
sum += part;
109109
offset += part;
110-
if (part < iov[i].iov_len)
110+
if ((size_t) part < iov[i].iov_len)
111111
return sum;
112112
}
113113
return sum;

0 commit comments

Comments
 (0)