crypto: not use vec api with opt_data[VNET_CRYPTO_N_OP_IDS] 75/23075/4
authorLijian Zhang <Lijian.Zhang@arm.com>
Fri, 27 Sep 2019 08:25:35 +0000 (16:25 +0800)
committerNeale Ranns <nranns@cisco.com>
Tue, 12 Nov 2019 16:57:11 +0000 (16:57 +0000)
opt_data is defined as a array, while in some code, e.g., function
 vnet_crypto_get_op_type, it's used as vec.
vec api is not applicable to static arraies.

src/vnet/crypto/crypto.h:234:70: error: address of array 'cm->opt_data' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  vnet_crypto_op_data_t *od = ({ do { if ((0 > 0) && ! ((id) < ((cm->opt_data) ? (((vec_header_t *) (cm->opt_data) - 1)->len) : 0)))

Type: fix

Change-Id: I0b6754406e4216ca975bc1da4b5d4ce293a9bb45
Signed-off-by: Lijian Zhang <Lijian.Zhang@arm.com>
src/vnet/crypto/cli.c
src/vnet/crypto/crypto.c
src/vnet/crypto/crypto.h

index 4b0e093..8d523ae 100644 (file)
@@ -71,7 +71,7 @@ format_vnet_crypto_handlers (u8 * s, va_list * args)
       if (id == 0)
        continue;
 
-      od = vec_elt_at_index (cm->opt_data, id);
+      od = cm->opt_data + id;
       if (first == 0)
         s = format (s, "\n%U", format_white_space, indent);
       s = format (s, "%-20U%-20U", format_vnet_crypto_op_type, od->type,
index 4da8a14..c465f14 100644 (file)
@@ -118,7 +118,7 @@ vnet_crypto_set_handler (char *alg_name, char *engine)
       vnet_crypto_op_id_t id = ad->op_by_type[i];
       if (id == 0)
        continue;
-      od = vec_elt_at_index (cm->opt_data, id);
+      od = cm->opt_data + id;
       if (ce->ops_handlers[id])
        {
          od->active_engine_index = p[0];
index 9326a07..626e71d 100644 (file)
@@ -231,7 +231,8 @@ static_always_inline vnet_crypto_op_type_t
 vnet_crypto_get_op_type (vnet_crypto_op_id_t id)
 {
   vnet_crypto_main_t *cm = &crypto_main;
-  vnet_crypto_op_data_t *od = vec_elt_at_index (cm->opt_data, id);
+  ASSERT (id < VNET_CRYPTO_N_OP_IDS);
+  vnet_crypto_op_data_t *od = cm->opt_data + id;
   return od->type;
 }