aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2017-11-02 11:59:14 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-11-05 11:35:57 +0000
commitfd67ece3d3eda0bd896aaa166d89b4f8e7f4e98f (patch)
treef8c725239953a91ba37f783805580cb21159f2e6 /src/vpp-api
parente4bb5bc7c153ec1b26abae00461aaf19f5541419 (diff)
Fix coverity warnings in VOM and VAPI
Change-Id: I0db55e079f9b1835668c8efe69e6e6f7f8437b00 Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/vapi/vapi.c6
-rw-r--r--src/vpp-api/vapi/vapi.hpp8
-rwxr-xr-xsrc/vpp-api/vapi/vapi_c_gen.py4
-rw-r--r--src/vpp-api/vapi/vapi_common.h4
-rw-r--r--src/vpp-api/vapi/vapi_internal.h4
-rw-r--r--src/vpp-api/vom/hw.hpp6
6 files changed, 19 insertions, 13 deletions
diff --git a/src/vpp-api/vapi/vapi.c b/src/vpp-api/vapi/vapi.c
index 25c0b3be1d3..658fd7e584c 100644
--- a/src/vpp-api/vapi/vapi.c
+++ b/src/vpp-api/vapi/vapi.c
@@ -238,7 +238,7 @@ vapi_lookup_vapi_msg_id_t (vapi_ctx_t ctx, u16 vl_msg_id)
{
return ctx->vl_msg_id_to_vapi_msg_t[vl_msg_id];
}
- return ~0;
+ return INVALID_MSG_ID;
}
vapi_error_e
@@ -337,7 +337,7 @@ vapi_connect (vapi_ctx_t ctx, const char *name,
u8 scratch[m->name_with_crc_len + 1];
memcpy (scratch, m->name_with_crc, m->name_with_crc_len + 1);
u32 id = vl_api_get_msg_index (scratch);
- if (~0 != id)
+ if (INVALID_MSG_ID != id)
{
if (id > UINT16_MAX)
{
@@ -716,7 +716,7 @@ vapi_dispatch_one (vapi_ctx_t ctx)
vapi_msg_free (ctx, msg);
return VAPI_EINVAL;
}
- if (~0 == (unsigned) ctx->vl_msg_id_to_vapi_msg_t[vpp_id])
+ if (INVALID_MSG_ID == (unsigned) ctx->vl_msg_id_to_vapi_msg_t[vpp_id])
{
VAPI_ERR ("Unknown msg ID received, id `%u' marked as not supported",
(unsigned) vpp_id);
diff --git a/src/vpp-api/vapi/vapi.hpp b/src/vpp-api/vapi/vapi.hpp
index e0fd2e5051c..893851a0dbb 100644
--- a/src/vpp-api/vapi/vapi.hpp
+++ b/src/vpp-api/vapi/vapi.hpp
@@ -105,7 +105,8 @@ public:
private:
Connection &con;
- Common_req (Connection &con) : con (con), response_state{RESPONSE_NOT_READY}
+ Common_req (Connection &con)
+ : con (con), context{0}, response_state{RESPONSE_NOT_READY}
{
}
@@ -577,13 +578,14 @@ private:
static void set_msg_id (vapi_msg_id_t id)
{
- assert ((~0 == *msg_id_holder ()) || (id == *msg_id_holder ()));
+ assert ((INVALID_MSG_ID == *msg_id_holder ()) ||
+ (id == *msg_id_holder ()));
*msg_id_holder () = id;
}
static vapi_msg_id_t *msg_id_holder ()
{
- static vapi_msg_id_t my_id{~0};
+ static vapi_msg_id_t my_id{INVALID_MSG_ID};
return &my_id;
}
diff --git a/src/vpp-api/vapi/vapi_c_gen.py b/src/vpp-api/vapi/vapi_c_gen.py
index d7a7272adff..4b7da6a1f15 100755
--- a/src/vpp-api/vapi/vapi_c_gen.py
+++ b/src/vpp-api/vapi/vapi_c_gen.py
@@ -504,11 +504,11 @@ class CMessage (Message):
' offsetof(%s, context),' % self.header.get_c_name()
if has_context else ' 0,',
(' offsetof(%s, payload),' % self.get_c_name())
- if self.has_payload() else ' ~0,',
+ if self.has_payload() else ' INVALID_MSG_ID,',
' sizeof(%s),' % self.get_c_name(),
' (generic_swap_fn_t)%s,' % self.get_swap_to_be_func_name(),
' (generic_swap_fn_t)%s,' % self.get_swap_to_host_func_name(),
- ' ~0,',
+ ' INVALID_MSG_ID,',
' };',
'',
' %s = vapi_register_msg(&%s);' %
diff --git a/src/vpp-api/vapi/vapi_common.h b/src/vpp-api/vapi/vapi_common.h
index ce64469d02c..764a0b71f50 100644
--- a/src/vpp-api/vapi/vapi_common.h
+++ b/src/vpp-api/vapi/vapi_common.h
@@ -52,7 +52,9 @@ typedef enum
VAPI_WAIT_FOR_READ_WRITE, /**< wait until a read or write can be done */
} vapi_wait_mode_e;
-typedef int vapi_msg_id_t;
+typedef unsigned int vapi_msg_id_t;
+
+#define INVALID_MSG_ID ((vapi_msg_id_t)(~0))
#ifdef __cplusplus
}
diff --git a/src/vpp-api/vapi/vapi_internal.h b/src/vpp-api/vapi/vapi_internal.h
index 2c51c673d9e..e9a9726d86e 100644
--- a/src/vpp-api/vapi/vapi_internal.h
+++ b/src/vpp-api/vapi/vapi_internal.h
@@ -90,8 +90,8 @@ typedef struct
const char *name_with_crc;
size_t name_with_crc_len;
bool has_context;
- int context_offset;
- int payload_offset;
+ unsigned int context_offset;
+ unsigned int payload_offset;
size_t size;
generic_swap_fn_t swap_to_be;
generic_swap_fn_t swap_to_host;
diff --git a/src/vpp-api/vom/hw.hpp b/src/vpp-api/vom/hw.hpp
index 00ab2d647f1..ef34a4c4542 100644
--- a/src/vpp-api/vom/hw.hpp
+++ b/src/vpp-api/vom/hw.hpp
@@ -54,7 +54,8 @@ public:
* Constructor
*/
item()
- : item_rc(rc_t::UNSET)
+ : item_data()
+ , item_rc(rc_t::UNSET)
{
}
@@ -62,7 +63,8 @@ public:
* Constructor
*/
item(rc_t rc)
- : item_rc(rc)
+ : item_data()
+ , item_rc(rc)
{
}