From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0726FA04FF; Wed, 13 Apr 2022 04:09:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3484C42805; Wed, 13 Apr 2022 04:09:43 +0200 (CEST) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 0A6B640E03 for ; Wed, 13 Apr 2022 04:09:40 +0200 (CEST) Received: by mail-pl1-f172.google.com with SMTP id t12so694550pll.7 for ; Tue, 12 Apr 2022 19:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kWCSyGgICbEu+X3N8HcLwsbVMiFZ1YrMxaEVTj7Is60=; b=CsSkAnLv2L/i0q1HTuBeMqQ0+Ss48dkqNi6vd9qJ0lWVJeu+ZMg3eifUMPMvU0wNb1 ToGZpQ+E08PHj4rucgyLwmHjL1Gq9czhH1tRd25t34rfMiJ6T/Q2GbZpbE2C2ietbyWP p8v3c/O1Cev8bWHguwdTdFN9B6zLp+WA83lfKxZYRB6a6QXhpPtla0xy8bHH4Di6ZNbg BppM0WczOVFfBJk+Eb/9S3qEICqLVwi6ZHwiWyh2DcHiHCZZtHKXcIIQwT4HI5q8Sgnj dZA3iRn4HiZPfQVWpPXSCjZtB3RVH6AHKIImr15qAeyV0RA4BbOzxnJ/4AYs6h1hz2Iv n0gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kWCSyGgICbEu+X3N8HcLwsbVMiFZ1YrMxaEVTj7Is60=; b=SAV2LC9nFsKWYsLNc3M+eLT/K9SlZdwq2JoVXL8+W4y7CfvgUJqVX70eOMUdYPgQHr pyaZ7cDLOay41hcK2c2Q45ELS9tjVwk4VCPJ0BAcVKKXVIEXE+BfdJ062x0t/wNiVAms 4FgQp9nBmrwhlrhLkCX6gA7YWineiaE1rjj5VCFFU8iH//w9xI/+oSq4Z2UaTVj71tAl aQivdXmIX2eFUk0TIabDpr7LQHFZsK2JJS87aE2V967h9priClQo3yXPaUwyEZmXjyyW BBHp879m8+j1dUfIpUiNzesL3O/X1kWbPNO1WZ8jIHBkrlJ6TPz4Uy0vrEXrfO8X+H8V kyXQ== X-Gm-Message-State: AOAM533SBh1+fRM3d/8EXDPXK2kMPQvzFE5xmJRXZsnmsdPLVsd+PWkd EdbRRjCZtSH5SRN5ncFcGdnSbOIdjOZ+3Q== X-Google-Smtp-Source: ABdhPJx8mIy+iHRUsWHZ7Q8Fo1xDPcdNmTWDaYaR3NCFepwTbJodY8iL43k6JyH79yN/0t5V5cyGmQ== X-Received: by 2002:a17:902:e882:b0:154:445d:9818 with SMTP id w2-20020a170902e88200b00154445d9818mr40395376plg.40.1649815779928; Tue, 12 Apr 2022 19:09:39 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id pg14-20020a17090b1e0e00b001c75634df70sm802553pjb.31.2022.04.12.19.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 19:09:39 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH 2/2] rib6: mark error tests with unlikely Date: Tue, 12 Apr 2022 19:09:34 -0700 Message-Id: <20220413020935.90499-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220413020935.90499-1-stephen@networkplumber.org> References: <20220413020935.90499-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Also mark some conditional functions as const. Signed-off-by: Stephen Hemminger --- lib/rib/rte_rib6.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c index 042ac1f090bf..650bf1b8f681 100644 --- a/lib/rib/rte_rib6.c +++ b/lib/rib/rte_rib6.c @@ -47,13 +47,13 @@ struct rte_rib6 { }; static inline bool -is_valid_node(struct rte_rib6_node *node) +is_valid_node(const struct rte_rib6_node *node) { return (node->flag & RTE_RIB_VALID_NODE) == RTE_RIB_VALID_NODE; } static inline bool -is_right_node(struct rte_rib6_node *node) +is_right_node(const struct rte_rib6_node *node) { return node->parent->right == node; } @@ -171,7 +171,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib, uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE]; int i; - if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) { + if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) { rte_errno = EINVAL; return NULL; } @@ -210,7 +210,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib, uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE]; int i; - if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) { + if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) { rte_errno = EINVAL; return NULL; } @@ -293,8 +293,7 @@ rte_rib6_insert(struct rte_rib6 *rib, int i, d; uint8_t common_depth, ip_xor; - if (unlikely((rib == NULL) || (ip == NULL) || - (depth > RIB6_MAXDEPTH))) { + if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) { rte_errno = EINVAL; return NULL; } @@ -413,7 +412,7 @@ int rte_rib6_get_ip(const struct rte_rib6_node *node, uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]) { - if ((node == NULL) || (ip == NULL)) { + if (unlikely(node == NULL || ip == NULL)) { rte_errno = EINVAL; return -1; } @@ -424,7 +423,7 @@ rte_rib6_get_ip(const struct rte_rib6_node *node, int rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth) { - if ((node == NULL) || (depth == NULL)) { + if (unlikely(node == NULL || depth == NULL)) { rte_errno = EINVAL; return -1; } @@ -441,7 +440,7 @@ rte_rib6_get_ext(struct rte_rib6_node *node) int rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh) { - if ((node == NULL) || (nh == NULL)) { + if (unlikely(node == NULL || nh == NULL)) { rte_errno = EINVAL; return -1; } @@ -452,7 +451,7 @@ rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh) int rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh) { - if (node == NULL) { + if (unlikely(node == NULL)) { rte_errno = EINVAL; return -1; } @@ -471,7 +470,7 @@ rte_rib6_create(const char *name, int socket_id, struct rte_mempool *node_pool; /* Check user arguments. */ - if (name == NULL || conf == NULL || conf->max_nodes <= 0) { + if (unlikely(name == NULL || conf == NULL || conf->max_nodes <= 0)) { rte_errno = EINVAL; return NULL; } @@ -506,7 +505,7 @@ rte_rib6_create(const char *name, int socket_id, /* allocate tailq entry */ te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0); - if (te == NULL) { + if (unlikely(te == NULL)) { RTE_LOG(ERR, LPM, "Can not allocate tailq entry for RIB6 %s\n", name); rte_errno = ENOMEM; @@ -516,7 +515,7 @@ rte_rib6_create(const char *name, int socket_id, /* Allocate memory to store the RIB6 data structures. */ rib = rte_zmalloc_socket(mem_name, sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id); - if (rib == NULL) { + if (unlikely(rib == NULL)) { RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name); rte_errno = ENOMEM; goto free_te; -- 2.35.1