diff mbox

net: Constify the checksum functions

Message ID 1471040594.12231.16.camel@kernel.crashing.org
State New
Headers show

Commit Message

Benjamin Herrenschmidt Aug. 12, 2016, 10:23 p.m. UTC
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 mbox

Patch

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;