[2/3] rib: check for invalid max_nodes

Message ID 20200625203208.19315-3-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series rib: minor fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Stephen Hemminger June 25, 2020, 8:32 p.m. UTC
  Max_nodes in config is signed, but a negative value makes
no sense. Get rid of extra BSD style parens.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_rib/rte_rib.c  | 3 +--
 lib/librte_rib/rte_rib6.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
  

Comments

Vladimir Medvedkin June 26, 2020, 2:03 p.m. UTC | #1
On 25/06/2020 21:32, Stephen Hemminger wrote:
> Max_nodes in config is signed, but a negative value makes
> no sense. Get rid of extra BSD style parens.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/librte_rib/rte_rib.c  | 3 +--
>   lib/librte_rib/rte_rib6.c | 3 +--
>   2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/lib/librte_rib/rte_rib.c b/lib/librte_rib/rte_rib.c
> index e40cf715c099..2a370d7f8439 100644
> --- a/lib/librte_rib/rte_rib.c
> +++ b/lib/librte_rib/rte_rib.c
> @@ -401,8 +401,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
>   	struct rte_mempool *node_pool;
>   
>   	/* Check user arguments. */
> -	if ((name == NULL) || (conf == NULL) ||
> -			(conf->max_nodes == 0)) {
> +	if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> diff --git a/lib/librte_rib/rte_rib6.c b/lib/librte_rib/rte_rib6.c
> index 02563b951620..f6c55ee454be 100644
> --- a/lib/librte_rib/rte_rib6.c
> +++ b/lib/librte_rib/rte_rib6.c
> @@ -460,8 +460,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 (name == NULL || conf == NULL || conf->max_nodes <= 0) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
  

Patch

diff --git a/lib/librte_rib/rte_rib.c b/lib/librte_rib/rte_rib.c
index e40cf715c099..2a370d7f8439 100644
--- a/lib/librte_rib/rte_rib.c
+++ b/lib/librte_rib/rte_rib.c
@@ -401,8 +401,7 @@  rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	struct rte_mempool *node_pool;
 
 	/* Check user arguments. */
-	if ((name == NULL) || (conf == NULL) ||
-			(conf->max_nodes == 0)) {
+	if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
diff --git a/lib/librte_rib/rte_rib6.c b/lib/librte_rib/rte_rib6.c
index 02563b951620..f6c55ee454be 100644
--- a/lib/librte_rib/rte_rib6.c
+++ b/lib/librte_rib/rte_rib6.c
@@ -460,8 +460,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 (name == NULL || conf == NULL || conf->max_nodes <= 0) {
 		rte_errno = EINVAL;
 		return NULL;
 	}