aboutgitcodebugslistschat
path: root/tap.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-09-29 15:50:19 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-10-04 23:23:35 +0200
commit6471c7d01b0aad9d144448290557fcd783562228 (patch)
tree07c664f50790f205080f64d02a2b860f3642e8f7 /tap.c
parentfc8f0f8c48ef12edbf60f74f37024917f5812385 (diff)
downloadpasst-6471c7d01b0aad9d144448290557fcd783562228.tar
passt-6471c7d01b0aad9d144448290557fcd783562228.tar.gz
passt-6471c7d01b0aad9d144448290557fcd783562228.tar.bz2
passt-6471c7d01b0aad9d144448290557fcd783562228.tar.lz
passt-6471c7d01b0aad9d144448290557fcd783562228.tar.xz
passt-6471c7d01b0aad9d144448290557fcd783562228.tar.zst
passt-6471c7d01b0aad9d144448290557fcd783562228.zip
cppcheck: Make many pointers const
Newer versions of cppcheck (as of 2.12.0, at least) added a warning for pointers which could be declared to point at const data, but aren't. Based on that, make many pointers throughout the codebase const. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tap.c')
-rw-r--r--tap.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tap.c b/tap.c
index 93db989..93bb348 100644
--- a/tap.c
+++ b/tap.c
@@ -203,7 +203,7 @@ void tap_udp4_send(const struct ctx *c, struct in_addr src, in_port_t sport,
* @len: ICMP packet length, including ICMP header
*/
void tap_icmp4_send(const struct ctx *c, struct in_addr src, struct in_addr dst,
- void *in, size_t len)
+ const void *in, size_t len)
{
char buf[USHRT_MAX];
void *ip4h = tap_push_l2h(c, buf, ETH_P_IP);
@@ -291,7 +291,7 @@ void tap_udp6_send(const struct ctx *c,
*/
void tap_icmp6_send(const struct ctx *c,
const struct in6_addr *src, const struct in6_addr *dst,
- void *in, size_t len)
+ const void *in, size_t len)
{
char buf[USHRT_MAX];
void *ip6h = tap_push_l2h(c, buf, ETH_P_IPV6);
@@ -315,7 +315,7 @@ void tap_icmp6_send(const struct ctx *c,
*
* #syscalls:pasta write
*/
-static size_t tap_send_frames_pasta(struct ctx *c,
+static size_t tap_send_frames_pasta(const struct ctx *c,
const struct iovec *iov, size_t n)
{
size_t i;
@@ -414,7 +414,7 @@ static size_t tap_send_frames_passt(const struct ctx *c,
* @iov: Array of buffers, each containing one frame (with L2 headers)
* @n: Number of buffers/frames in @iov
*/
-void tap_send_frames(struct ctx *c, const struct iovec *iov, size_t n)
+void tap_send_frames(const struct ctx *c, const struct iovec *iov, size_t n)
{
size_t m;
@@ -706,7 +706,7 @@ append:
}
for (j = 0, seq = tap4_l4; j < seq_count; j++, seq++) {
- struct pool *p = (struct pool *)&seq->p;
+ const struct pool *p = (const struct pool *)&seq->p;
size_t k;
tap_packet_debug(NULL, NULL, seq, 0, NULL, p->count);
@@ -869,7 +869,7 @@ append:
}
for (j = 0, seq = tap6_l4; j < seq_count; j++, seq++) {
- struct pool *p = (struct pool *)&seq->p;
+ const struct pool *p = (const struct pool *)&seq->p;
size_t k;
tap_packet_debug(NULL, NULL, NULL, seq->protocol, seq,
@@ -1022,7 +1022,7 @@ redo:
pool_flush(pool_tap6);
restart:
while ((len = read(c->fd_tap, pkt_buf + n, TAP_BUF_BYTES - n)) > 0) {
- struct ethhdr *eh = (struct ethhdr *)(pkt_buf + n);
+ const struct ethhdr *eh = (struct ethhdr *)(pkt_buf + n);
if (len < (ssize_t)sizeof(*eh) || len > (ssize_t)ETH_MAX_MTU) {
n += len;