summaryrefslogtreecommitdiffstats
path: root/vppinfra
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-08-08 13:05:31 -0400
committerDave Barach <dave@barachs.net>2016-08-08 13:09:15 -0400
commit6f6f34f620a18638eb820a9ab3d8a93e350d722a (patch)
treef0e03e0a2e96b10511561e5868a4ff741a9386f4 /vppinfra
parent06e3d075760be43dbd61385d3c7861cd5fe44af2 (diff)
VPP-189 Clean up more coverity warnings
Change-Id: If66713d79c545c762c385faf08cc809347741152 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vppinfra')
-rw-r--r--vppinfra/Makefile.am21
-rw-r--r--vppinfra/vppinfra/elf.c10
-rw-r--r--vppinfra/vppinfra/hash.c6
-rw-r--r--vppinfra/vppinfra/heap.h2
-rw-r--r--vppinfra/vppinfra/serialize.c5
-rw-r--r--vppinfra/vppinfra/slist.c3
-rw-r--r--vppinfra/vppinfra/timer.c2
7 files changed, 17 insertions, 32 deletions
diff --git a/vppinfra/Makefile.am b/vppinfra/Makefile.am
index a70e7ce2084..a9de5ad03b3 100644
--- a/vppinfra/Makefile.am
+++ b/vppinfra/Makefile.am
@@ -35,11 +35,8 @@ TESTS += test_bihash_template \
test_macros \
test_md5 \
test_mheap \
- test_pfhash \
- test_phash \
test_pool_iterate \
test_ptclosure \
- test_qhash \
test_random \
test_random_isaac \
test_serialize \
@@ -66,11 +63,8 @@ test_longjmp_SOURCES = vppinfra/test_longjmp.c
test_macros_SOURCES = vppinfra/test_macros.c
test_md5_SOURCES = vppinfra/test_md5.c
test_mheap_SOURCES = vppinfra/test_mheap.c
-test_pfhash_SOURCES = vppinfra/test_pfhash.c
-test_phash_SOURCES = vppinfra/test_phash.c
test_pool_iterate_SOURCES = vppinfra/test_pool_iterate.c
test_ptclosure_SOURCES = vppinfra/test_ptclosure.c
-test_qhash_SOURCES = vppinfra/test_qhash.c
test_random_SOURCES = vppinfra/test_random.c
test_random_isaac_SOURCES = vppinfra/test_random_isaac.c
test_serialize_SOURCES = vppinfra/test_serialize.c
@@ -95,11 +89,8 @@ test_longjmp_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_macros_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_md5_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_mheap_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
-test_pfhash_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
-test_phash_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_pool_iterate_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_ptclosure_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
-test_qhash_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_random_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_random_isaac_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_socket_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
@@ -122,11 +113,8 @@ test_longjmp_LDADD = libvppinfra.la
test_macros_LDADD = libvppinfra.la
test_md5_LDADD = libvppinfra.la
test_mheap_LDADD = libvppinfra.la
-test_pfhash_LDADD = libvppinfra.la
-test_phash_LDADD = libvppinfra.la
test_pool_iterate_LDADD = libvppinfra.la
test_ptclosure_LDADD = libvppinfra.la
-test_qhash_LDADD = libvppinfra.la
test_random_LDADD = libvppinfra.la
test_random_isaac_LDADD = libvppinfra.la
test_serialize_LDADD = libvppinfra.la
@@ -149,11 +137,8 @@ test_longjmp_LDFLAGS = -static
test_macros_LDFLAGS = -static
test_md5_LDFLAGS = -static
test_mheap_LDFLAGS = -static
-test_pfhash_LDFLAGS = -static
-test_phash_LDFLAGS = -static
test_pool_iterate_LDFLAGS = -static
test_ptclosure_LDFLAGS = -static
-test_qhash_LDFLAGS = -static
test_random_LDFLAGS = -static
test_random_isaac_LDFLAGS = -static
test_serialize_LDFLAGS = -static
@@ -206,12 +191,9 @@ nobase_include_HEADERS = \
vppinfra/mheap.h \
vppinfra/mheap_bootstrap.h \
vppinfra/os.h \
- vppinfra/pfhash.h \
- vppinfra/phash.h \
vppinfra/pipeline.h \
vppinfra/pool.h \
vppinfra/ptclosure.h \
- vppinfra/qhash.h \
vppinfra/random.h \
vppinfra/random_buffer.h \
vppinfra/random_isaac.h \
@@ -259,10 +241,7 @@ CLIB_CORE = \
vppinfra/mheap.c \
vppinfra/md5.c \
vppinfra/mem_mheap.c \
- vppinfra/pfhash.c \
- vppinfra/phash.c \
vppinfra/ptclosure.c \
- vppinfra/qhash.c \
vppinfra/random.c \
vppinfra/random_buffer.c \
vppinfra/random_isaac.c \
diff --git a/vppinfra/vppinfra/elf.c b/vppinfra/vppinfra/elf.c
index 71ae1d33d70..8c5dc6c33e0 100644
--- a/vppinfra/vppinfra/elf.c
+++ b/vppinfra/vppinfra/elf.c
@@ -582,7 +582,7 @@ format_elf_main (u8 * s, va_list * args)
s = format (s, "\nSegments: %d at file offset 0x%Lx-0x%Lx:\n",
fh->segment_header_count,
fh->segment_header_file_offset,
- fh->segment_header_file_offset + fh->segment_header_count * fh->segment_header_size);
+ (u64) fh->segment_header_file_offset + fh->segment_header_count * fh->segment_header_size);
s = format (s, "%U\n", format_elf_segment, 0);
vec_foreach (h, copy)
@@ -1827,8 +1827,12 @@ clib_error_t * elf_write_file (elf_main_t * em, char * file_name)
/* Finally write section headers. */
if (fseek (f, em->file_header.section_header_file_offset, SEEK_SET) < 0)
- return clib_error_return_unix (0, "fseek 0x%Lx", em->file_header.section_header_file_offset);
-
+ {
+ fclose(f);
+ return clib_error_return_unix
+ (0, "fseek 0x%Lx", em->file_header.section_header_file_offset);
+ }
+
vec_foreach (s, em->sections)
{
elf64_section_header_t h;
diff --git a/vppinfra/vppinfra/hash.c b/vppinfra/vppinfra/hash.c
index 86231b4db5e..c4d724935a5 100644
--- a/vppinfra/vppinfra/hash.c
+++ b/vppinfra/vppinfra/hash.c
@@ -346,7 +346,7 @@ set_indirect_is_user (void * v,
else
{
log2_bytes = 1 + hash_pair_log2_bytes (h);
- q = clib_mem_alloc (1 << log2_bytes);
+ q = clib_mem_alloc (1ULL << log2_bytes);
}
clib_memcpy (q, &p->direct, hash_pair_bytes (h));
@@ -388,7 +388,7 @@ set_indirect (void * v, hash_pair_indirect_t * pi, uword key,
log2_bytes = indirect_pair_get_log2_bytes (pi);
new_len = len + 1;
- if (new_len * hash_pair_bytes (h) > (1 << log2_bytes))
+ if (new_len * hash_pair_bytes (h) > (1ULL << log2_bytes))
{
pi->pairs = clib_mem_realloc (pi->pairs,
1 << (log2_bytes + 1),
@@ -649,7 +649,7 @@ void * _hash_create (uword elts, hash_t * h_user)
/* Size of hash is power of 2 >= ELTS and larger than
number of bits in is_user bitmap elements. */
elts = clib_max (elts, BITS (h->is_user[0]));
- elts = 1 << max_log2 (elts);
+ elts = 1ULL << max_log2 (elts);
log2_pair_size = 1;
if (h_user)
diff --git a/vppinfra/vppinfra/heap.h b/vppinfra/vppinfra/heap.h
index c6605dac5f0..604187c00ea 100644
--- a/vppinfra/vppinfra/heap.h
+++ b/vppinfra/vppinfra/heap.h
@@ -194,7 +194,7 @@ uword heap_bytes (void * v);
always_inline void * _heap_new (u32 len, u32 n_elt_bytes)
{
- void * v = _vec_resize (0, len, len*n_elt_bytes,
+ void * v = _vec_resize (0, len, (uword) len*n_elt_bytes,
sizeof (heap_header_t),
HEAP_DATA_ALIGN);
heap_header (v)->elt_bytes = n_elt_bytes;
diff --git a/vppinfra/vppinfra/serialize.c b/vppinfra/vppinfra/serialize.c
index 4025b704700..9c6987dd0e9 100644
--- a/vppinfra/vppinfra/serialize.c
+++ b/vppinfra/vppinfra/serialize.c
@@ -281,7 +281,8 @@ unserialize_vector_ha (serialize_main_t * m,
unserialize_integer (m, &l, sizeof (l));
if (l > max_length)
serialize_error (&m->header, clib_error_create ("bad vector length %d", l));
- p = v = _vec_resize (0, l, l*elt_bytes, header_bytes, /* align */ align);
+ p = v = _vec_resize (0, l, (uword) l*elt_bytes, header_bytes,
+ /* align */ align);
while (l != 0)
{
@@ -407,7 +408,7 @@ unserialize_pool_helper (serialize_main_t * m,
return 0;
}
- v = _vec_resize (0, l, l*elt_bytes, sizeof (p[0]), align);
+ v = _vec_resize (0, l, (uword) l*elt_bytes, sizeof (p[0]), align);
p = pool_header (v);
vec_unserialize (m, &p->free_indices, unserialize_vec_32);
diff --git a/vppinfra/vppinfra/slist.c b/vppinfra/vppinfra/slist.c
index 19302b69aaa..435a026a462 100644
--- a/vppinfra/vppinfra/slist.c
+++ b/vppinfra/vppinfra/slist.c
@@ -299,7 +299,8 @@ u8 * format_slist (u8 * s, va_list *args)
for (i = 0; i < vec_len (head_elt->n.nexts); i++)
{
- s = format (s, "level %d: %d elts\n", i, sl->occupancy[i]);
+ s = format (s, "level %d: %d elts\n", i,
+ sl->occupancy ? sl->occupancy[i] : 0);
if (verbose && head_elt->n.nexts[i] != (u32)~0)
{
diff --git a/vppinfra/vppinfra/timer.c b/vppinfra/vppinfra/timer.c
index 2b2c958729d..2c71417f289 100644
--- a/vppinfra/vppinfra/timer.c
+++ b/vppinfra/vppinfra/timer.c
@@ -158,8 +158,8 @@ void timer_call (timer_func_t * func, any arg, f64 dt)
/* Initialize time_resolution before first call to timer_interrupt */
time_resolution = 0.75 / (f64) HZ;
+ memset (&sa, 0, sizeof (sa));
sa.sa_handler = timer_interrupt;
- sa.sa_flags = 0;
if (sigaction (TIMER_SIGNAL, &sa, 0) < 0)
clib_panic ("sigaction");