On 32-bit architectures, it's a regular int. C99 introduced ptrdiff_t
for this case, with a matching length modifier, 't'.
Signed-off-by: Stefano Brivio
---
tcp.c | 39 +++++++++++++++++++++------------------
tcp_splice.c | 14 +++++++-------
2 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/tcp.c b/tcp.c
index 44468ca..c32c9cb 100644
--- a/tcp.c
+++ b/tcp.c
@@ -727,7 +727,7 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
it.it_value.tv_sec = ACT_TIMEOUT;
}
- debug("TCP: index %li, timer expires in %lu.%03lus", CONN_IDX(conn),
+ debug("TCP: index %ti, timer expires in %lu.%03lus", CONN_IDX(conn),
it.it_value.tv_sec, it.it_value.tv_nsec / 1000 / 1000);
timerfd_settime(conn->timer, 0, &it, NULL);
@@ -750,7 +750,7 @@ static void conn_flag_do(const struct ctx *c, struct tcp_tap_conn *conn,
conn->flags &= flag;
if (flag_index >= 0) {
- debug("TCP: index %li: %s dropped", CONN_IDX(conn),
+ debug("TCP: index %ti: %s dropped", CONN_IDX(conn),
tcp_flag_str[flag_index]);
}
} else {
@@ -771,7 +771,7 @@ static void conn_flag_do(const struct ctx *c, struct tcp_tap_conn *conn,
conn->flags |= flag;
if (flag_index >= 0) {
- debug("TCP: index %li: %s", CONN_IDX(conn),
+ debug("TCP: index %ti: %s", CONN_IDX(conn),
tcp_flag_str[flag_index]);
}
}
@@ -821,12 +821,12 @@ static void conn_event_do(const struct ctx *c, struct tcp_tap_conn *conn,
new += 5;
if (prev != new) {
- debug("TCP: index %li, %s: %s -> %s", CONN_IDX(conn),
+ debug("TCP: index %ti, %s: %s -> %s", CONN_IDX(conn),
num == -1 ? "CLOSED" : tcp_event_str[num],
prev == -1 ? "CLOSED" : tcp_state_str[prev],
(new == -1 || num == -1) ? "CLOSED" : tcp_state_str[new]);
} else {
- debug("TCP: index %li, %s", CONN_IDX(conn),
+ debug("TCP: index %ti, %s", CONN_IDX(conn),
num == -1 ? "CLOSED" : tcp_event_str[num]);
}
@@ -1209,7 +1209,7 @@ static void tcp_hash_insert(const struct ctx *c, struct tcp_tap_conn *conn)
conn->next_index = tc_hash[b] ? CONN_IDX(tc_hash[b]) : -1;
tc_hash[b] = conn;
- debug("TCP: hash table insert: index %li, sock %i, bucket: %i, next: "
+ debug("TCP: hash table insert: index %ti, sock %i, bucket: %i, next: "
"%p", CONN_IDX(conn), conn->sock, b,
(void *)conn_at_idx(conn->next_index));
}
@@ -1236,7 +1236,7 @@ static void tcp_hash_remove(const struct ctx *c,
}
}
- debug("TCP: hash table remove: index %li, sock %i, bucket: %i, new: %p",
+ debug("TCP: hash table remove: index %ti, sock %i, bucket: %i, new: %p",
CONN_IDX(conn), conn->sock, b,
(void *)(prev ? conn_at_idx(prev->next_index) : tc_hash[b]));
}
@@ -1264,7 +1264,7 @@ static void tcp_tap_conn_update(const struct ctx *c, struct tcp_tap_conn *old,
}
}
- debug("TCP: hash table update: old index %li, new index %li, sock %i, "
+ debug("TCP: hash table update: old index %ti, new index %ti, sock %i, "
"bucket: %i, old: %p, new: %p",
CONN_IDX(old), CONN_IDX(new), new->sock, b,
(void *)old, (void *)new);
@@ -1310,7 +1310,7 @@ void tcp_table_compact(struct ctx *c, union tcp_conn *hole)
union tcp_conn *from;
if (CONN_IDX(hole) == --c->tcp.conn_count) {
- debug("TCP: table compaction: maximum index was %li (%p)",
+ debug("TCP: table compaction: maximum index was %ti (%p)",
CONN_IDX(hole), (void *)hole);
memset(hole, 0, sizeof(*hole));
return;
@@ -1324,8 +1324,8 @@ void tcp_table_compact(struct ctx *c, union tcp_conn *hole)
else
tcp_tap_conn_update(c, &from->tap, &hole->tap);
- debug("TCP: table compaction (spliced=%d): old index %li, new index %li, "
- "from: %p, to: %p",
+ debug("TCP: table compaction (spliced=%d): old index %ti, new index %ti"
+ ", from: %p, to: %p",
from->c.spliced, CONN_IDX(from), CONN_IDX(hole),
(void *)from, (void *)hole);
@@ -1352,7 +1352,7 @@ static void tcp_conn_destroy(struct ctx *c, union tcp_conn *conn_union)
static void tcp_rst_do(struct ctx *c, struct tcp_tap_conn *conn);
#define tcp_rst(c, conn) \
do { \
- debug("TCP: index %li, reset at %s:%i", CONN_IDX(conn), \
+ debug("TCP: index %ti, reset at %s:%i", CONN_IDX(conn), \
__func__, __LINE__); \
tcp_rst_do(c, conn); \
} while (0)
@@ -2570,7 +2570,7 @@ int tcp_tap_handler(struct ctx *c, uint8_t pif, int af,
return 1;
}
- trace("TCP: packet length %zu from tap for index %lu",
+ trace("TCP: packet length %zu from tap for index %ti",
len, CONN_IDX(conn));
if (th->rst) {
@@ -2811,17 +2811,19 @@ void tcp_timer_handler(struct ctx *c, union epoll_ref ref)
tcp_timer_ctl(c, conn);
} else if (conn->flags & ACK_FROM_TAP_DUE) {
if (!(conn->events & ESTABLISHED)) {
- debug("TCP: index %li, handshake timeout", CONN_IDX(conn));
+ debug("TCP: index %ti, handshake timeout",
+ CONN_IDX(conn));
tcp_rst(c, conn);
} else if (CONN_HAS(conn, SOCK_FIN_SENT | TAP_FIN_ACKED)) {
- debug("TCP: index %li, FIN timeout", CONN_IDX(conn));
+ debug("TCP: index %ti, FIN timeout", CONN_IDX(conn));
tcp_rst(c, conn);
} else if (conn->retrans == TCP_MAX_RETRANS) {
- debug("TCP: index %li, retransmissions count exceeded",
+ debug("TCP: index %ti, retransmissions count exceeded",
CONN_IDX(conn));
tcp_rst(c, conn);
} else {
- debug("TCP: index %li, ACK timeout, retry", CONN_IDX(conn));
+ debug("TCP: index %ti, ACK timeout, retry",
+ CONN_IDX(conn));
conn->retrans++;
conn->seq_to_tap = conn->seq_ack_from_tap;
tcp_data_from_sock(c, conn);
@@ -2839,7 +2841,8 @@ void tcp_timer_handler(struct ctx *c, union epoll_ref ref)
*/
timerfd_settime(conn->timer, 0, &new, &old);
if (old.it_value.tv_sec == ACT_TIMEOUT) {
- debug("TCP: index %li, activity timeout", CONN_IDX(conn));
+ debug("TCP: index %ti, activity timeout",
+ CONN_IDX(conn));
tcp_rst(c, conn);
}
}
diff --git a/tcp_splice.c b/tcp_splice.c
index 8d08bb4..cb8a73e 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -138,7 +138,7 @@ static int tcp_splice_epoll_ctl(const struct ctx *c,
if (epoll_ctl(c->epollfd, m, conn->s[0], &ev[0]) ||
epoll_ctl(c->epollfd, m, conn->s[1], &ev[1])) {
int ret = -errno;
- err("TCP (spliced): index %li, ERROR on epoll_ctl(): %s",
+ err("TCP (spliced): index %ti, ERROR on epoll_ctl(): %s",
CONN_IDX(conn), strerror(errno));
return ret;
}
@@ -165,8 +165,8 @@ static void conn_flag_do(const struct ctx *c, struct tcp_splice_conn *conn,
conn->flags &= flag;
if (flag_index >= 0) {
- debug("TCP (spliced): index %li: %s dropped", CONN_IDX(conn),
- tcp_splice_flag_str[flag_index]);
+ debug("TCP (spliced): index %ti: %s dropped",
+ CONN_IDX(conn), tcp_splice_flag_str[flag_index]);
}
} else {
int flag_index = fls(flag);
@@ -176,7 +176,7 @@ static void conn_flag_do(const struct ctx *c, struct tcp_splice_conn *conn,
conn->flags |= flag;
if (flag_index >= 0) {
- debug("TCP (spliced): index %li: %s", CONN_IDX(conn),
+ debug("TCP (spliced): index %ti: %s", CONN_IDX(conn),
tcp_splice_flag_str[flag_index]);
}
}
@@ -211,7 +211,7 @@ static void conn_event_do(const struct ctx *c, struct tcp_splice_conn *conn,
conn->events &= event;
if (flag_index >= 0) {
- debug("TCP (spliced): index %li, ~%s", CONN_IDX(conn),
+ debug("TCP (spliced): index %ti, ~%s", CONN_IDX(conn),
tcp_splice_event_str[flag_index]);
}
} else {
@@ -222,7 +222,7 @@ static void conn_event_do(const struct ctx *c, struct tcp_splice_conn *conn,
conn->events |= event;
if (flag_index >= 0) {
- debug("TCP (spliced): index %li, %s", CONN_IDX(conn),
+ debug("TCP (spliced): index %ti, %s", CONN_IDX(conn),
tcp_splice_event_str[flag_index]);
}
}
@@ -280,7 +280,7 @@ void tcp_splice_destroy(struct ctx *c, union tcp_conn *conn_union)
conn->events = SPLICE_CLOSED;
conn->flags = 0;
- debug("TCP (spliced): index %li, CLOSED", CONN_IDX(conn));
+ debug("TCP (spliced): index %ti, CLOSED", CONN_IDX(conn));
tcp_table_compact(c, conn_union);
}
--
2.39.2