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: 9278101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 808B860780 for ; Fri, 12 Aug 2016 22:23:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 643EE28AEA for ; Fri, 12 Aug 2016 22:23:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55B7428B1B; Fri, 12 Aug 2016 22:23:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9507628AEA for ; Fri, 12 Aug 2016 22:23:47 +0000 (UTC) Received: from localhost ([::1]:55088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYKrf-0000oG-OJ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Aug 2016 18:23:43 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;