aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-07-13 11:22:23 -0400
committerDave Barach <dave@barachs.net>2018-07-13 11:26:36 -0400
commita8d476468d6dad10f0d55423eded2a2a065f8478 (patch)
treecb3e8996bfb2d2d5ad26cd3bc4c73abcf4746d27 /src
parentb9124828bf34f0f545c412555d0b094933813ba1 (diff)
VPP-1338: fix ipsec api coverity warnings
Remove useless unsigned comparisions: "(unsigned) value < 0", correct a couple of incorrect limit checks. Change-Id: I9606c4057df157f770d59535457cb9df1cfd1f35 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c12
-rw-r--r--src/vnet/ipsec/ipsec_api.c7
2 files changed, 7 insertions, 12 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 9ee74aa9d37..647277315e8 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -15128,8 +15128,7 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam)
if (unformat
(i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
{
- if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
- crypto_alg >= IPSEC_CRYPTO_N_ALG)
+ if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
{
clib_warning ("unsupported crypto-alg: '%U'",
format_ipsec_crypto_alg, crypto_alg);
@@ -15142,8 +15141,7 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam)
if (unformat
(i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
{
- if (integ_alg < IPSEC_INTEG_ALG_NONE ||
- integ_alg >= IPSEC_INTEG_N_ALG)
+ if (integ_alg >= IPSEC_INTEG_N_ALG)
{
clib_warning ("unsupported integ-alg: '%U'",
format_ipsec_integ_alg, integ_alg);
@@ -15300,8 +15298,7 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam)
if (unformat
(i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
{
- if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
- crypto_alg >= IPSEC_CRYPTO_N_ALG)
+ if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
{
errmsg ("unsupported crypto-alg: '%U'\n",
format_ipsec_crypto_alg, crypto_alg);
@@ -15312,8 +15309,7 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam)
if (unformat
(i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
{
- if (integ_alg < IPSEC_INTEG_ALG_NONE ||
- integ_alg >= IPSEC_INTEG_N_ALG)
+ if (integ_alg >= IPSEC_INTEG_N_ALG)
{
errmsg ("unsupported integ-alg: '%U'\n",
format_ipsec_integ_alg, integ_alg);
diff --git a/src/vnet/ipsec/ipsec_api.c b/src/vnet/ipsec/ipsec_api.c
index fc7d481ecb1..8ea47b7ebe1 100644
--- a/src/vnet/ipsec/ipsec_api.c
+++ b/src/vnet/ipsec/ipsec_api.c
@@ -194,8 +194,7 @@ static void vl_api_ipsec_sad_add_del_entry_t_handler
sa.spi = ntohl (mp->spi);
sa.protocol = mp->protocol;
/* check for unsupported crypto-alg */
- if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_NONE ||
- mp->crypto_algorithm >= IPSEC_CRYPTO_N_ALG)
+ if (mp->crypto_algorithm >= IPSEC_CRYPTO_N_ALG)
{
clib_warning ("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg,
mp->crypto_algorithm);
@@ -527,7 +526,7 @@ vl_api_ipsec_tunnel_if_set_key_t_handler (vl_api_ipsec_tunnel_if_set_key_t *
case IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO:
case IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO:
if (mp->alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
- mp->alg > IPSEC_CRYPTO_N_ALG)
+ mp->alg >= IPSEC_CRYPTO_N_ALG)
{
rv = VNET_API_ERROR_UNIMPLEMENTED;
goto out;
@@ -535,7 +534,7 @@ vl_api_ipsec_tunnel_if_set_key_t_handler (vl_api_ipsec_tunnel_if_set_key_t *
break;
case IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG:
case IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG:
- if (mp->alg > IPSEC_INTEG_N_ALG)
+ if (mp->alg >= IPSEC_INTEG_N_ALG)
{
rv = VNET_API_ERROR_UNIMPLEMENTED;
goto out;