net: Constify the checksum functions
PATCH 1/1 net: Constify the checksum functions
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 <[email protected]>
--- include/net/checksum.h | 10 +++++----- net/checksum.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-)
include/net/checksum.h +5 -5
@@ -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)); }
net/checksum.c +3 -3
@@ -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;