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 671DAA051C; Fri, 26 Jun 2020 16:03:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 397FB1BFB4; Fri, 26 Jun 2020 16:03:32 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id A9A231BFA6 for ; Fri, 26 Jun 2020 16:03:29 +0200 (CEST) IronPort-SDR: KIdY5ZA0tlR4ghdRZeNP3s2iZDryp4JruA0VCYYY0Z8nqUSvFVEy4DL0sweMve4LvGUem9KD7x FjMmqj9Lb/fg== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="133706799" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208,217";a="133706799" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 07:03:28 -0700 IronPort-SDR: yWvAzUY2ciWxg8eItHIAlRNSH8mcFm33HnFr7ZemYAV9+pDx4esB3QRoiRY07FnEd873+wwo9l Qab/ViIZIs/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208,217";a="276374199" Received: from vmedvedk-mobl.ger.corp.intel.com (HELO [10.251.170.129]) ([10.251.170.129]) by orsmga003.jf.intel.com with ESMTP; 26 Jun 2020 07:03:26 -0700 To: Stephen Hemminger Cc: dev@dpdk.org References: <20200625203208.19315-1-stephen@networkplumber.org> <20200625203208.19315-2-stephen@networkplumber.org> From: "Medvedkin, Vladimir" Message-ID: Date: Fri, 26 Jun 2020 15:03:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200625203208.19315-2-stephen@networkplumber.org> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [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" On 25/06/2020 21:32, Stephen Hemminger wrote: > 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. Acked-by: Vladimir Medvedkin -- Regards, Vladimir