summaryrefslogtreecommitdiffstats
path: root/vppinfra
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-08-05 10:10:18 -0400
committerDave Barach <dave@barachs.net>2016-08-05 10:10:38 -0400
commitf9c231ec12c2233557bfbb58feb87a1fcddf224a (patch)
tree6ee8846be9a6c79d68d0364c00cc58b2f3547ddd /vppinfra
parent56faee837281c7f9c28aa40dbf0f6e4620b76be8 (diff)
vpp-189 Clean up more coverity warnings
Time to make the donuts Change-Id: I528937800f7daefce19723dda0216e58d857942c Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vppinfra')
-rw-r--r--vppinfra/tools/elftool.c13
-rw-r--r--vppinfra/vppinfra/asm_x86.c4
-rw-r--r--vppinfra/vppinfra/bitmap.h4
-rw-r--r--vppinfra/vppinfra/elf.c11
-rw-r--r--vppinfra/vppinfra/elf_clib.c8
-rw-r--r--vppinfra/vppinfra/elog.c2
6 files changed, 31 insertions, 11 deletions
diff --git a/vppinfra/tools/elftool.c b/vppinfra/tools/elftool.c
index f5d70b56d5f..d9d3704b4a3 100644
--- a/vppinfra/tools/elftool.c
+++ b/vppinfra/tools/elftool.c
@@ -358,10 +358,12 @@ set_interpreter_rpath (elf_tool_main_t * tm)
}
done:
- if (mmap_length > 0)
+ if (mmap_length > 0 && idp)
munmap (idp, mmap_length);
- close (ifd);
- close (ofd);
+ if (ifd >= 0)
+ close (ifd);
+ if (ofd >= 0)
+ close (ofd);
return error;
}
@@ -408,7 +410,10 @@ int main (int argc, char * argv[])
}
if (! tm->input_file)
- clib_error ("no input file");
+ {
+ error = clib_error_return (0, "no input file");
+ goto done;
+ }
/* Do the typical case a stone-simple way... */
if (tm->quiet && tm->set_interpreter && tm->set_rpath && tm->output_file)
diff --git a/vppinfra/vppinfra/asm_x86.c b/vppinfra/vppinfra/asm_x86.c
index d89739cbd90..16e41c249b1 100644
--- a/vppinfra/vppinfra/asm_x86.c
+++ b/vppinfra/vppinfra/asm_x86.c
@@ -1736,6 +1736,7 @@ static u8 * format_x86_reg_operand (u8 * s, va_list * va)
{
default:
ASSERT (0);
+ break;
case 'x':
ASSERT (reg < 16);
@@ -1816,6 +1817,7 @@ static u8 * format_x86_insn_operand (u8 * s, va_list * va)
/* Memory or reg field from modrm byte. */
case 'M':
ASSERT (p->flags & X86_INSN_IS_ADDRESS);
+ /* FALLTHROUGH */
case 'E':
if (p->flags & X86_INSN_IS_ADDRESS)
s = format (s, "%U", format_x86_mem_operand, p);
@@ -1836,7 +1838,7 @@ static u8 * format_x86_insn_operand (u8 * s, va_list * va)
case 'I':
{
u32 l = x86_insn_log2_immediate_bytes (p, insn);
- i64 mask = pow2_mask (8 << l);
+ i64 mask = pow2_mask (8ULL << l);
s = format (s, "$0x%Lx", p->immediate & mask);
}
break;
diff --git a/vppinfra/vppinfra/bitmap.h b/vppinfra/vppinfra/bitmap.h
index 35de1b4819f..17b72ac6c1f 100644
--- a/vppinfra/vppinfra/bitmap.h
+++ b/vppinfra/vppinfra/bitmap.h
@@ -196,7 +196,7 @@ clib_bitmap_get_multiple (uword * bitmap, uword i, uword n_bits)
uword i0, i1, result;
uword l = vec_len (bitmap);
- ASSERT (n_bits >= 0 && n_bits <= BITS (result));
+ ASSERT (n_bits <= BITS (result));
i0 = i / BITS (bitmap[0]);
i1 = i % BITS (bitmap[0]);
@@ -229,7 +229,7 @@ clib_bitmap_set_multiple (uword * bitmap, uword i, uword value, uword n_bits)
{
uword i0, i1, l, t, m;
- ASSERT (n_bits >= 0 && n_bits <= BITS (value));
+ ASSERT (n_bits <= BITS (value));
i0 = i / BITS (bitmap[0]);
i1 = i % BITS (bitmap[0]);
diff --git a/vppinfra/vppinfra/elf.c b/vppinfra/vppinfra/elf.c
index 7fe3048b4c7..71ae1d33d70 100644
--- a/vppinfra/vppinfra/elf.c
+++ b/vppinfra/vppinfra/elf.c
@@ -559,7 +559,8 @@ format_elf_main (u8 * s, va_list * args)
s = format (s, "\nSections %d at file offset 0x%Lx-0x%Lx:\n",
fh->section_header_count,
fh->section_header_file_offset,
- fh->section_header_file_offset + fh->section_header_count * fh->section_header_size);
+ fh->section_header_file_offset +
+ (u64) fh->section_header_count * fh->section_header_size);
s = format (s, "%U\n", format_elf_section, em, 0);
vec_foreach (h, copy)
s = format (s, "%U\n", format_elf_section, em, h);
@@ -1604,7 +1605,7 @@ static void layout_sections (elf_main_t * em)
fh->section_header_file_offset = file_offset;
fh->section_header_count = vec_len (em->sections) - n_deleted_sections;
- file_offset += fh->section_header_count * fh->section_header_size;
+ file_offset += (u64) fh->section_header_count * fh->section_header_size;
}
{
@@ -1809,7 +1810,11 @@ clib_error_t * elf_write_file (elf_main_t * em, char * file_name)
continue;
if (fseek (f, s->header.file_offset, SEEK_SET) < 0)
- return clib_error_return_unix (0, "fseek 0x%Lx", s->header.file_offset);
+ {
+ fclose(f);
+ return clib_error_return_unix (0, "fseek 0x%Lx",
+ s->header.file_offset);
+ }
if (s->header.type == ELF_SECTION_NO_BITS)
/* don't write for .bss sections */;
diff --git a/vppinfra/vppinfra/elf_clib.c b/vppinfra/vppinfra/elf_clib.c
index f3d3b32a8c5..8c705488a4b 100644
--- a/vppinfra/vppinfra/elf_clib.c
+++ b/vppinfra/vppinfra/elf_clib.c
@@ -82,6 +82,9 @@ path_search (char * file)
if (file[0] == '.' || file[0] == '/')
return file;
+ if (getenv("PATH") == 0)
+ return file;
+
ps.path = split_string (getenv ("PATH"), ':');
for (i = 0; i < vec_len (ps.path); i++)
@@ -231,7 +234,10 @@ add_section (struct dl_phdr_info * info, size_t size, void * opaque)
name = path_search (cem->exec_path);
if (! name)
- clib_error ("failed to find %s on PATH", cem->exec_path);
+ {
+ clib_error ("failed to find %s on PATH", cem->exec_path);
+ return 0;
+ }
addr = 0;
}
diff --git a/vppinfra/vppinfra/elog.c b/vppinfra/vppinfra/elog.c
index 06b97d8a390..7ae4ea1d2e2 100644
--- a/vppinfra/vppinfra/elog.c
+++ b/vppinfra/vppinfra/elog.c
@@ -582,6 +582,8 @@ void elog_merge (elog_main_t * dst, u8 * dst_tag,
elog_track_t newt;
int i;
+ memset(&newt, 0, sizeof (newt));
+
elog_get_events (src);
elog_get_events (dst);