treewide: Use 'z' length modifier for size_t/ssize_t conversions
Types size_t and ssize_t are not necessarily long, it depends on the architecture. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
4117bd94f9
commit
06559048e7
6 changed files with 22 additions and 21 deletions
|
@ -130,7 +130,7 @@ static uint32_t nl_send(int s, void *req, uint16_t type,
|
|||
if (n < 0)
|
||||
die("netlink: Failed to send(): %s", strerror(errno));
|
||||
else if (n < len)
|
||||
die("netlink: Short send (%lu of %lu bytes)", n, len);
|
||||
die("netlink: Short send (%zd of %zd bytes)", n, len);
|
||||
|
||||
return nh->nlmsg_seq;
|
||||
}
|
||||
|
|
14
packet.c
14
packet.c
|
@ -36,7 +36,7 @@ void packet_add_do(struct pool *p, size_t len, const char *start,
|
|||
size_t idx = p->count;
|
||||
|
||||
if (idx >= p->size) {
|
||||
trace("add packet index %lu to pool with size %lu, %s:%i",
|
||||
trace("add packet index %zu to pool with size %zu, %s:%i",
|
||||
idx, p->size, func, line);
|
||||
return;
|
||||
}
|
||||
|
@ -48,14 +48,14 @@ void packet_add_do(struct pool *p, size_t len, const char *start,
|
|||
}
|
||||
|
||||
if (start + len > p->buf + p->buf_size) {
|
||||
trace("add packet start %p, length: %lu, buffer end %p, %s:%i",
|
||||
trace("add packet start %p, length: %zu, buffer end %p, %s:%i",
|
||||
(void *)start, len, (void *)(p->buf + p->buf_size),
|
||||
func, line);
|
||||
return;
|
||||
}
|
||||
|
||||
if (len > UINT16_MAX) {
|
||||
trace("add packet length %lu, %s:%i", len, func, line);
|
||||
trace("add packet length %zu, %s:%i", len, func, line);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ void *packet_get_do(const struct pool *p, size_t idx, size_t offset,
|
|||
{
|
||||
if (idx >= p->size || idx >= p->count) {
|
||||
if (func) {
|
||||
trace("packet %lu from pool size: %lu, count: %lu, "
|
||||
trace("packet %zu from pool size: %zu, count: %zu, "
|
||||
"%s:%i", idx, p->size, p->count, func, line);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -98,7 +98,7 @@ void *packet_get_do(const struct pool *p, size_t idx, size_t offset,
|
|||
|
||||
if (len > UINT16_MAX || len + offset > UINT32_MAX) {
|
||||
if (func) {
|
||||
trace("packet data length %lu, offset %lu, %s:%i",
|
||||
trace("packet data length %zu, offset %zu, %s:%i",
|
||||
len, offset, func, line);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -106,7 +106,7 @@ void *packet_get_do(const struct pool *p, size_t idx, size_t offset,
|
|||
|
||||
if (p->pkt[idx].offset + len + offset > p->buf_size) {
|
||||
if (func) {
|
||||
trace("packet offset plus length %lu from size %lu, "
|
||||
trace("packet offset plus length %lu from size %zu, "
|
||||
"%s:%i", p->pkt[idx].offset + len + offset,
|
||||
p->buf_size, func, line);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void *packet_get_do(const struct pool *p, size_t idx, size_t offset,
|
|||
|
||||
if (len + offset > p->pkt[idx].len) {
|
||||
if (func) {
|
||||
trace("data length %lu, offset %lu from length %u, "
|
||||
trace("data length %zu, offset %zu from length %u, "
|
||||
"%s:%i", len, offset, p->pkt[idx].len,
|
||||
func, line);
|
||||
}
|
||||
|
|
4
pcap.c
4
pcap.c
|
@ -101,7 +101,7 @@ void pcap(const char *pkt, size_t len)
|
|||
|
||||
gettimeofday(&tv, NULL);
|
||||
if (pcap_frame(pkt, len, &tv) != 0)
|
||||
debug("Cannot log packet, length %lu", len);
|
||||
debug("Cannot log packet, length %zu", len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ void pcap_multiple(const struct iovec *iov, unsigned int n, size_t offset)
|
|||
for (i = 0; i < n; i++) {
|
||||
if (pcap_frame((char *)iov[i].iov_base + offset,
|
||||
iov[i].iov_len - offset, &tv) != 0) {
|
||||
debug("Cannot log packet, length %lu",
|
||||
debug("Cannot log packet, length %zu",
|
||||
iov->iov_len - offset);
|
||||
return;
|
||||
}
|
||||
|
|
12
tap.c
12
tap.c
|
@ -191,7 +191,7 @@ void tap_udp4_send(const struct ctx *c, struct in_addr src, in_port_t sport,
|
|||
memcpy(data, in, len);
|
||||
|
||||
if (tap_send(c, buf, len + (data - buf)) < 0)
|
||||
debug("tap: failed to send %lu bytes (IPv4)", len);
|
||||
debug("tap: failed to send %zu bytes (IPv4)", len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -214,7 +214,7 @@ void tap_icmp4_send(const struct ctx *c, struct in_addr src, struct in_addr dst,
|
|||
csum_icmp4(icmp4h, icmp4h + 1, len - sizeof(*icmp4h));
|
||||
|
||||
if (tap_send(c, buf, len + (data - buf)) < 0)
|
||||
debug("tap: failed to send %lu bytes (IPv4)", len);
|
||||
debug("tap: failed to send %zu bytes (IPv4)", len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,7 +278,7 @@ void tap_udp6_send(const struct ctx *c,
|
|||
memcpy(data, in, len);
|
||||
|
||||
if (tap_send(c, buf, len + (data - buf)) < 1)
|
||||
debug("tap: failed to send %lu bytes (IPv6)", len);
|
||||
debug("tap: failed to send %zu bytes (IPv6)", len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -302,7 +302,7 @@ void tap_icmp6_send(const struct ctx *c,
|
|||
csum_icmp6(icmp6h, src, dst, icmp6h + 1, len - sizeof(*icmp6h));
|
||||
|
||||
if (tap_send(c, buf, len + (data - buf)) < 1)
|
||||
debug("tap: failed to send %lu bytes (IPv6)", len);
|
||||
debug("tap: failed to send %zu bytes (IPv6)", len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,7 +364,7 @@ static void tap_send_remainder(const struct ctx *c, const struct iovec *iov,
|
|||
ssize_t sent = send(c->fd_tap, base + offset, len - offset,
|
||||
MSG_NOSIGNAL);
|
||||
if (sent < 0) {
|
||||
err("tap: partial frame send (missing %lu bytes): %s",
|
||||
err("tap: partial frame send (missing %zu bytes): %s",
|
||||
len - offset, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ size_t tap_send_frames(const struct ctx *c, const struct iovec *iov, size_t n)
|
|||
m = tap_send_frames_pasta(c, iov, n);
|
||||
|
||||
if (m < n)
|
||||
debug("tap: failed to send %lu frames of %lu", n - m, n);
|
||||
debug("tap: failed to send %zu frames of %zu", n - m, n);
|
||||
|
||||
pcap_multiple(iov, m, c->mode == MODE_PASST ? sizeof(uint32_t) : 0);
|
||||
|
||||
|
|
3
tcp.c
3
tcp.c
|
@ -2570,7 +2570,8 @@ int tcp_tap_handler(struct ctx *c, uint8_t pif, int af,
|
|||
return 1;
|
||||
}
|
||||
|
||||
trace("TCP: packet length %lu from tap for index %lu", len, CONN_IDX(conn));
|
||||
trace("TCP: packet length %zu from tap for index %lu",
|
||||
len, CONN_IDX(conn));
|
||||
|
||||
if (th->rst) {
|
||||
conn_event(c, conn, CLOSED);
|
||||
|
|
|
@ -321,7 +321,7 @@ static int tcp_splice_connect_finish(const struct ctx *c,
|
|||
|
||||
if (fcntl(conn->pipe[side][0], F_SETPIPE_SZ,
|
||||
c->tcp.pipe_size)) {
|
||||
trace("TCP (spliced): cannot set %d->%d pipe size to %lu",
|
||||
trace("TCP (spliced): cannot set %d->%d pipe size to %zu",
|
||||
side, !side, c->tcp.pipe_size);
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ retry:
|
|||
readlen = splice(conn->s[fromside], NULL,
|
||||
conn->pipe[fromside][1], NULL, c->tcp.pipe_size,
|
||||
SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
|
||||
trace("TCP (spliced): %li from read-side call", readlen);
|
||||
trace("TCP (spliced): %zi from read-side call", readlen);
|
||||
if (readlen < 0) {
|
||||
if (errno == EINTR)
|
||||
goto retry;
|
||||
|
@ -580,7 +580,7 @@ eintr:
|
|||
written = splice(conn->pipe[fromside][0], NULL,
|
||||
conn->s[!fromside], NULL, to_write,
|
||||
SPLICE_F_MOVE | more | SPLICE_F_NONBLOCK);
|
||||
trace("TCP (spliced): %li from write-side call (passed %lu)",
|
||||
trace("TCP (spliced): %zi from write-side call (passed %zi)",
|
||||
written, to_write);
|
||||
|
||||
/* Most common case: skip updating counters. */
|
||||
|
@ -718,7 +718,7 @@ static void tcp_splice_pipe_refill(const struct ctx *c)
|
|||
|
||||
if (fcntl(splice_pipe_pool[i][0], F_SETPIPE_SZ,
|
||||
c->tcp.pipe_size)) {
|
||||
trace("TCP (spliced): cannot set pool pipe size to %lu",
|
||||
trace("TCP (spliced): cannot set pool pipe size to %zu",
|
||||
c->tcp.pipe_size);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue