From patchwork Fri Aug 12 22:23:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 658890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s9zvJ4Vsgz9sR9 for ; Sat, 13 Aug 2016 08:24:10 +1000 (AEST) Received: from localhost ([::1]:55089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYKs3-00015j-CX for incoming@patchwork.ozlabs.org; Fri, 12 Aug 2016 18:24:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYKrO-0000o7-Hh for qemu-devel@nongnu.org; Fri, 12 Aug 2016 18:23:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bYKrJ-0003lS-AV for qemu-devel@nongnu.org; Fri, 12 Aug 2016 18:23:25 -0400 Received: from gate.crashing.org ([63.228.1.57]:53698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYKrJ-0003lL-14 for qemu-devel@nongnu.org; Fri, 12 Aug 2016 18:23:21 -0400 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id u7CMNFUt026953 for ; Fri, 12 Aug 2016 17:23:17 -0500 Message-ID: <1471040594.12231.16.camel@kernel.crashing.org> From: Benjamin Herrenschmidt To: QEMU Developers Date: Sat, 13 Aug 2016 08:23:14 +1000 X-Mailer: Evolution 3.20.4 (3.20.4-1.fc24) Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 63.228.1.57 Subject: [Qemu-devel] [PATCH] net: Constify the checksum functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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;