From d35973833e6bf05fec29100a4d5e66bb07b06659 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 24 Apr 2018 16:39:35 -0700 Subject: fix a number of cppcheck complaints (not all) --- src/core/message.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/core/message.c') diff --git a/src/core/message.c b/src/core/message.c index 35153f01..5c396f21 100644 --- a/src/core/message.c +++ b/src/core/message.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Garrett D'Amore -// Copyright 2017 Capitar IT Group BV +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -102,7 +102,6 @@ nni_msg_dump(const char *banner, const nni_msg *msg) static int nni_chunk_grow(nni_chunk *ch, size_t newsz, size_t headwanted) { - size_t headroom = 0; uint8_t *newbuf; // We assume that if the pointer is a valid pointer, and inside @@ -121,7 +120,7 @@ nni_chunk_grow(nni_chunk *ch, size_t newsz, size_t headwanted) if ((ch->ch_ptr >= ch->ch_buf) && (ch->ch_ptr < (ch->ch_buf + ch->ch_cap))) { - headroom = (size_t)(ch->ch_ptr - ch->ch_buf); + size_t headroom = (size_t)(ch->ch_ptr - ch->ch_buf); if (headwanted < headroom) { headwanted = headroom; // Never shrink this. } @@ -474,10 +473,9 @@ nni_msg_getopt(nni_msg *m, int opt, void *val, size_t *szp) int nni_msg_realloc(nni_msg *m, size_t sz) { - int rv = 0; - if (m->m_body.ch_len < sz) { - rv = nni_chunk_append(&m->m_body, NULL, sz - m->m_body.ch_len); + int rv = + nni_chunk_append(&m->m_body, NULL, sz - m->m_body.ch_len); if (rv != 0) { return (rv); } -- cgit v1.2.3-70-g09d2