From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E491DA0350; Thu, 25 Jun 2020 22:32:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8DA8414581; Thu, 25 Jun 2020 22:32:21 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 99F995F69 for ; Thu, 25 Jun 2020 22:32:18 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id p11so3561349pff.11 for ; Thu, 25 Jun 2020 13:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=urf9lxsuXl6D/ffo2WxIW8vnreHxJjmWZUkOBO604Ns=; b=NHG/mfpr247P9czxHfdrLnWjnG+id6Myoqq+Wxo/6fD4xNFJy3jaadvTxXOA/lunuZ UGV/CWMxCfWI4xiu/5wmYp5CXNtETpImuTBkE9OTsT3ci9pRwPjSGCRUnisKECkF/Pwz SzMWhZI4IRFhzsXqdVfe5gLU6ENr/8WPCBys8f7grjNaD0ArAi41fcUHuGXOWNwTlUip 1yXPkAuV2er4lnJHhA0oUSjQXxyLhrEIjn08e9I4NoBLvFUL1EinuGcVjN9B+nas0urk eA4zeXvxx5kOafwdNybbgFuUJul++KwCH62NFgyR2bUlN/airmnOlXn6sVoivUDg8gEw HzcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=urf9lxsuXl6D/ffo2WxIW8vnreHxJjmWZUkOBO604Ns=; b=DAhUYSO0xNF9+OmFalmgI3yoi9kRIqVlHAQ8tEg3K4ndtxhFtR5QEZtkWxcQpJD5kq JQQIP7FkizUFjCUZ0FY9evAgZChE5mxwWYrlRlXa+dBWUTqHR3nIJqZd4JQ2gmmLkTf0 ptLsI4I4Ut2pquuwmETADmWT0cgq7IvIr234R4Wh6Py7CQ8Rtp38N4VdhejzcARSFkmu GV64dviSZjr2cR4ktWb0/jG34/9H5yncoZsrc0HXQrH1L3S0mUMItTxZL4UNxTtuB+YC 35nUqHCUnOdOAIzXhFY7SsZaz5yAYyr8VDdJvgamZ0exi1rwN0C3hPybraBADPTa1CUI wUEA== X-Gm-Message-State: AOAM530PcqWR8NgBMnkqwSrizHkvZytA7NIA/0x3YgTz4dg6qFqMkK7H 4bPCqxGu7kPOSWsVilrkD44Dgl6NnKw= X-Google-Smtp-Source: ABdhPJxd3bscT3otOWmUNWO7OEnYXZvzsqhW2Jdf3aGjGFQIHzPOn3Vg/GK6d9yoUDU2pquH738rog== X-Received: by 2002:a63:9342:: with SMTP id w2mr7550785pgm.20.1593117137663; Thu, 25 Jun 2020 13:32:17 -0700 (PDT) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id i12sm23963007pfk.180.2020.06.25.13.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 13:32:16 -0700 (PDT) From: Stephen Hemminger To: "Medvedkin, Vladimir" Cc: dev@dpdk.org, Stephen Hemminger Date: Thu, 25 Jun 2020 13:32:06 -0700 Message-Id: <20200625203208.19315-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200625203208.19315-1-stephen@networkplumber.org> References: <20200625203208.19315-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/3] rib: constify arguments X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The getter functions should take a constant pointer to make it clear that node is not modified. The rib create functions do not modify their config structure. Mark the config as constant so that programs can pass simple constant data. Signed-off-by: Stephen Hemminger --- lib/librte_rib/rte_rib.c | 8 ++++---- lib/librte_rib/rte_rib.h | 9 +++++---- lib/librte_rib/rte_rib6.c | 10 ++++++---- lib/librte_rib/rte_rib6.h | 13 +++++++------ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/librte_rib/rte_rib.c b/lib/librte_rib/rte_rib.c index 55d612dc2e27..e40cf715c099 100644 --- a/lib/librte_rib/rte_rib.c +++ b/lib/librte_rib/rte_rib.c @@ -342,7 +342,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth) } int -rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip) +rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip) { if ((node == NULL) || (ip == NULL)) { rte_errno = EINVAL; @@ -353,7 +353,7 @@ rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip) } int -rte_rib_get_depth(struct rte_rib_node *node, uint8_t *depth) +rte_rib_get_depth(const struct rte_rib_node *node, uint8_t *depth) { if ((node == NULL) || (depth == NULL)) { rte_errno = EINVAL; @@ -370,7 +370,7 @@ rte_rib_get_ext(struct rte_rib_node *node) } int -rte_rib_get_nh(struct rte_rib_node *node, uint64_t *nh) +rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh) { if ((node == NULL) || (nh == NULL)) { rte_errno = EINVAL; @@ -392,7 +392,7 @@ rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh) } struct rte_rib * -rte_rib_create(const char *name, int socket_id, struct rte_rib_conf *conf) +rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf) { char mem_name[RTE_RIB_NAMESIZE]; struct rte_rib *rib = NULL; diff --git a/lib/librte_rib/rte_rib.h b/lib/librte_rib/rte_rib.h index 6b70de980a2c..a7daa9d8a76e 100644 --- a/lib/librte_rib/rte_rib.h +++ b/lib/librte_rib/rte_rib.h @@ -171,7 +171,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth); */ __rte_experimental int -rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip); +rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip); /** * Get a depth from rte_rib_node @@ -186,7 +186,7 @@ rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip); */ __rte_experimental int -rte_rib_get_depth(struct rte_rib_node *node, uint8_t *depth); +rte_rib_get_depth(const struct rte_rib_node *node, uint8_t *depth); /** * Get ext field from the rib node @@ -215,7 +215,7 @@ rte_rib_get_ext(struct rte_rib_node *node); */ __rte_experimental int -rte_rib_get_nh(struct rte_rib_node *node, uint64_t *nh); +rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh); /** * Set nexthop into the rib node @@ -247,7 +247,8 @@ rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh); */ __rte_experimental struct rte_rib * -rte_rib_create(const char *name, int socket_id, struct rte_rib_conf *conf); +rte_rib_create(const char *name, int socket_id, + const struct rte_rib_conf *conf); /** * Find an existing RIB object and return a pointer to it. diff --git a/lib/librte_rib/rte_rib6.c b/lib/librte_rib/rte_rib6.c index 78b8dcfd94a9..02563b951620 100644 --- a/lib/librte_rib/rte_rib6.c +++ b/lib/librte_rib/rte_rib6.c @@ -399,7 +399,8 @@ rte_rib6_insert(struct rte_rib6 *rib, } int -rte_rib6_get_ip(struct rte_rib6_node *node, uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]) +rte_rib6_get_ip(const struct rte_rib6_node *node, + uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]) { if ((node == NULL) || (ip == NULL)) { rte_errno = EINVAL; @@ -410,7 +411,7 @@ rte_rib6_get_ip(struct rte_rib6_node *node, uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]) } int -rte_rib6_get_depth(struct rte_rib6_node *node, uint8_t *depth) +rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth) { if ((node == NULL) || (depth == NULL)) { rte_errno = EINVAL; @@ -427,7 +428,7 @@ rte_rib6_get_ext(struct rte_rib6_node *node) } int -rte_rib6_get_nh(struct rte_rib6_node *node, uint64_t *nh) +rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh) { if ((node == NULL) || (nh == NULL)) { rte_errno = EINVAL; @@ -449,7 +450,8 @@ rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh) } struct rte_rib6 * -rte_rib6_create(const char *name, int socket_id, struct rte_rib6_conf *conf) +rte_rib6_create(const char *name, int socket_id, + const struct rte_rib6_conf *conf) { char mem_name[RTE_RIB6_NAMESIZE]; struct rte_rib6 *rib = NULL; diff --git a/lib/librte_rib/rte_rib6.h b/lib/librte_rib/rte_rib6.h index 871457138d7b..e6b4b7fff98c 100644 --- a/lib/librte_rib/rte_rib6.h +++ b/lib/librte_rib/rte_rib6.h @@ -70,7 +70,7 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src) * 0 otherwise */ static inline int -rte_rib6_is_equal(uint8_t *ip1, uint8_t *ip2) { +rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) { int i; if ((ip1 == NULL) || (ip2 == NULL)) @@ -227,8 +227,8 @@ rte_rib6_insert(struct rte_rib6 *rib, */ __rte_experimental int -rte_rib6_get_ip(struct rte_rib6_node *node, - uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]); +rte_rib6_get_ip(const struct rte_rib6_node *node, + uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]); /** * Get a depth from rte_rib6_node @@ -243,7 +243,7 @@ rte_rib6_get_ip(struct rte_rib6_node *node, */ __rte_experimental int -rte_rib6_get_depth(struct rte_rib6_node *node, uint8_t *depth); +rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth); /** * Get ext field from the rte_rib6_node @@ -272,7 +272,7 @@ rte_rib6_get_ext(struct rte_rib6_node *node); */ __rte_experimental int -rte_rib6_get_nh(struct rte_rib6_node *node, uint64_t *nh); +rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh); /** * Set nexthop into the rte_rib6_node @@ -304,7 +304,8 @@ rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh); */ __rte_experimental struct rte_rib6 * -rte_rib6_create(const char *name, int socket_id, struct rte_rib6_conf *conf); +rte_rib6_create(const char *name, int socket_id, + const struct rte_rib6_conf *conf); /** * Find an existing RIB object and return a pointer to it. -- 2.26.2