From e9aebf9db548b940c77f7c5826a1260d1931e75d Mon Sep 17 00:00:00 2001 From: Chris Luke Date: Wed, 4 Oct 2017 13:59:14 -0400 Subject: 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 --- src/vlibmemory/socket_client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/vlibmemory') diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c index 8519e7f5f7c..b60fd4f6229 100644 --- a/src/vlibmemory/socket_client.c +++ b/src/vlibmemory/socket_client.c @@ -166,16 +166,16 @@ vl_socket_client_connect (socket_client_main_t * scm, char *socket_path, mbp = (msgbuf_t *) buffer; mbp->q = 0; - mbp->data_len = ntohl (sizeof (*mp)); + mbp->data_len = htonl (sizeof (*mp)); mbp->gc_mark_timestamp = 0; mp = (vl_api_sockclnt_create_t *) mbp->data; - mp->_vl_msg_id = ntohs (VL_API_SOCKCLNT_CREATE); + mp->_vl_msg_id = htons (VL_API_SOCKCLNT_CREATE); strncpy ((char *) mp->name, client_name, sizeof (mp->name) - 1); mp->name[sizeof (mp->name) - 1] = 0; mp->context = 0xfeedface; - n = write (scm->socket_fd, mbp, sizeof (*mbp) + ntohl (mbp->data_len)); + n = write (scm->socket_fd, mbp, sizeof (*mbp) + sizeof (*mp)); if (n < 0) { clib_unix_warning ("socket write (msg)"); -- cgit 1.2.3-korg