* [Qemu-devel] [PATCH] net: Constify the checksum functions
@ 2016-08-12 22:23 Benjamin Herrenschmidt
0 siblings, 0 replies; only message in thread
From: Benjamin Herrenschmidt @ 2016-08-12 22:23 UTC (permalink / raw)
To: QEMU Developers
They never touch the buffer, it should be const, this helps when
drivers want to pass const pointers.
This is purely signature changes, there are no actual code changes.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
include/net/checksum.h | 10 +++++-----
net/checksum.c | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/net/checksum.h b/include/net/checksum.h
index 7df472c..091f547 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -21,20 +21,20 @@
#include "qemu/bswap.h"
struct iovec;
-uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq);
+uint32_t net_checksum_add_cont(int len, const uint8_t *buf, int seq);
uint16_t net_checksum_finish(uint32_t sum);
uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
- uint8_t *addrs, uint8_t *buf);
-void net_checksum_calculate(uint8_t *data, int length);
+ const uint8_t *addrs, const uint8_t *buf);
+void net_checksum_calculate(const uint8_t *data, int length);
static inline uint32_t
-net_checksum_add(int len, uint8_t *buf)
+net_checksum_add(int len, const uint8_t *buf)
{
return net_checksum_add_cont(len, buf, 0);
}
static inline uint16_t
-net_raw_checksum(uint8_t *data, int length)
+net_raw_checksum(const uint8_t *data, int length)
{
return net_checksum_finish(net_checksum_add(length, data));
}
diff --git a/net/checksum.c b/net/checksum.c
index 23323b0..2da95bd 100644
--- a/net/checksum.c
+++ b/net/checksum.c
@@ -20,7 +20,7 @@
#include "net/checksum.h"
#include "net/eth.h"
-uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq)
+uint32_t net_checksum_add_cont(int len, const uint8_t *buf, int seq)
{
uint32_t sum = 0;
int i;
@@ -43,7 +43,7 @@ uint16_t net_checksum_finish(uint32_t sum)
}
uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
- uint8_t *addrs, uint8_t *buf)
+ const uint8_t *addrs, const uint8_t *buf)
{
uint32_t sum = 0;
@@ -53,7 +53,7 @@ uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
return net_checksum_finish(sum);
}
-void net_checksum_calculate(uint8_t *data, int length)
+void net_checksum_calculate(const uint8_t *data, int length)
{
int mac_hdr_len, ip_len;
struct ip_header *ip;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-12 22:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-12 22:23 [Qemu-devel] [PATCH] net: Constify the checksum functions Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).