diff options
author | Dave Barach <dave@barachs.net> | 2016-08-08 13:05:31 -0400 |
---|---|---|
committer | Dave Barach <dave@barachs.net> | 2016-08-08 13:09:15 -0400 |
commit | 6f6f34f620a18638eb820a9ab3d8a93e350d722a (patch) | |
tree | f0e03e0a2e96b10511561e5868a4ff741a9386f4 /vppinfra/vppinfra | |
parent | 06e3d075760be43dbd61385d3c7861cd5fe44af2 (diff) |
VPP-189 Clean up more coverity warnings
Change-Id: If66713d79c545c762c385faf08cc809347741152
Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vppinfra/vppinfra')
-rw-r--r-- | vppinfra/vppinfra/elf.c | 10 | ||||
-rw-r--r-- | vppinfra/vppinfra/hash.c | 6 | ||||
-rw-r--r-- | vppinfra/vppinfra/heap.h | 2 | ||||
-rw-r--r-- | vppinfra/vppinfra/serialize.c | 5 | ||||
-rw-r--r-- | vppinfra/vppinfra/slist.c | 3 | ||||
-rw-r--r-- | vppinfra/vppinfra/timer.c | 2 |
6 files changed, 17 insertions, 11 deletions
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"); |