aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlibapi/vat_helper_macros.h
diff options
context:
space:
mode:
authorChris Luke <chrisy@flirble.org>2017-10-04 13:59:14 -0400
committerFlorin Coras <florin.coras@gmail.com>2017-10-06 23:02:47 +0000
commite9aebf9db548b940c77f7c5826a1260d1931e75d (patch)
tree2173932a2e69d4a4b2819ed1471f52e964a51204 /src/vlibapi/vat_helper_macros.h
parentf7f809c298104dc3026106fb498f474d5d8720cc (diff)
Coverity fixes for API socket
- Coverity whines about a zero-length field not being initialized. Change the struct setup to an initializer which will implicitly zero all unused fields, and add the coverity notation that should stop it whining. One or both of these should shut it up! - Fix some incorrect use of ntohl that was tainting values; in these cases htonl should have been used, and avoid a double-swap. Change-Id: I00493a77eb23a0b8feb647165ee349e1e9d5cfdb Signed-off-by: Chris Luke <chrisy@flirble.org>
Diffstat (limited to 'src/vlibapi/vat_helper_macros.h')
-rw-r--r--src/vlibapi/vat_helper_macros.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h
index 5e7f1083947..fd2e563512f 100644
--- a/src/vlibapi/vat_helper_macros.h
+++ b/src/vlibapi/vat_helper_macros.h
@@ -77,12 +77,14 @@ do { \
socket_client_main_t *scm = &vam->socket_client_main; \
if (scm->socket_enable) \
{ \
- msgbuf_t msgbuf; \
- \
- msgbuf.q = 0; \
- msgbuf.gc_mark_timestamp = 0; \
- msgbuf.data_len = ntohl(scm->socket_tx_nbytes); \
+ msgbuf_t msgbuf = \
+ { \
+ .q = 0, \
+ .gc_mark_timestamp = 0, \
+ .data_len = htonl(scm->socket_tx_nbytes), \
+ }; \
\
+ /* coverity[UNINIT] */ \
n = write (scm->socket_fd, &msgbuf, sizeof (msgbuf)); \
if (n < sizeof (msgbuf)) \
clib_unix_warning ("socket write (msgbuf)"); \