more avoiding of void pointer arithmetics

This time with a temporary variable to avoid not to trigger
-Wpointer-sign, sigh.
This commit is contained in:
Omar Polo 2023-06-13 17:36:42 +00:00
parent b90faa1605
commit 1959cda3d8
1 changed files with 6 additions and 4 deletions

View File

@ -83,17 +83,18 @@ prepare_header(struct fcgi_header *h, int type, int id, size_t size,
static void static void
must_read(int sock, void *d, size_t len) must_read(int sock, void *d, size_t len)
{ {
uint8_t *data = d;
ssize_t r; ssize_t r;
while (len > 0) { while (len > 0) {
switch (r = read(sock, d, len)) { switch (r = read(sock, data, len)) {
case -1: case -1:
err(1, "read"); err(1, "read");
case 0: case 0:
errx(1, "EOF"); errx(1, "EOF");
default: default:
len -= r; len -= r;
d += r; data += r;
} }
} }
} }
@ -101,17 +102,18 @@ must_read(int sock, void *d, size_t len)
static void static void
must_write(int sock, const void *d, size_t len) must_write(int sock, const void *d, size_t len)
{ {
const uint8_t *data = d;
ssize_t w; ssize_t w;
while (len > 0) { while (len > 0) {
switch (w = write(sock, d, len)) { switch (w = write(sock, data, len)) {
case -1: case -1:
err(1, "write"); err(1, "write");
case 0: case 0:
errx(1, "EOF"); errx(1, "EOF");
default: default:
len -= w; len -= w;
d += w; data += w;
} }
} }
} }