Fix some cppcheck warnings and bugs

This commit is contained in:
Cary R 2015-12-19 17:18:15 -08:00
parent 2aaa050b7c
commit 399384d81b
8 changed files with 36 additions and 32 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2015 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -32,6 +32,7 @@ Module::Module(LexicalScope*parent, perm_string n)
{
library_flag = false;
is_cell = false;
is_interface = false;
program_block = false;
uc_drive = UCD_NONE;
timescale_warn_done = false;

View File

@ -1,3 +1,3 @@
// These are correct and are used to find the base (zero) pin.
thisSubtraction:netlist.h:4976
thisSubtraction:netlist.h:4985
thisSubtraction:netlist.h:4991
thisSubtraction:netlist.h:5000

View File

@ -1277,7 +1277,6 @@ unsigned PECallFunction::test_width_method_(Design*des, NetScope*scope,
return 0;
perm_string member_name;
ivl_type_t member_type = 0;
pform_name_t use_path = path_;
perm_string method_name = peek_tail_name(use_path);
use_path.pop_back();
@ -1317,11 +1316,8 @@ unsigned PECallFunction::test_width_method_(Design*des, NetScope*scope,
const netclass_t* class_type = net->class_type();
int midx = class_type->property_idx_from_name(member_name);
if (midx >= 0)
member_type = class_type->get_prop_type(midx);
else
member_type = 0;
use_path = tmp_path;
ivl_type_t member_type = 0;
if (midx >= 0) member_type = class_type->get_prop_type(midx);
use_darray = dynamic_cast<const netdarray_t*> (member_type);
@ -3936,7 +3932,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
if ( !(SYS_TASK_ARG & flags) ) {
// I cannot interpret this identifier. Error message.
cerr << get_fileline() << ": error: Unable to bind "
<< (NEED_CONST & flags ? "parameter" : "wire/reg/memory")
<< ((NEED_CONST & flags) ? "parameter" : "wire/reg/memory")
<< " `" << path_ << "' in `" << scope_path(scope) << "'"
<< endl;
if (scope->need_const_func()) {

View File

@ -733,12 +733,18 @@ NetNet* NetEConcat::synthesize(Design*des, NetScope*scope, NetExpr*root)
}
}
if (flag == false) return 0;
if (flag == false) {
delete[]tmp;
return 0;
}
ivl_assert(*this, data_type != IVL_VT_NO_TYPE);
/* If this is a replication of zero just return 0. */
if (expr_width() == 0) return 0;
if (expr_width() == 0) {
delete[]tmp;
return 0;
}
/* Make a NetNet object to carry the output vector. */
perm_string path = scope->local_symbol();

View File

@ -162,13 +162,13 @@ verinum::V Nexus::driven_value() const
if ((sig->type() == NetNet::SUPPLY0) ||
(sig->type() == NetNet::TRI0)) {
// Multiple drivers are not currently supported.
ivl_assert(*obj, val == verinum::Vz);
ivl_assert(*sig, val == verinum::Vz);
val = verinum::V0;
}
if ((sig->type() == NetNet::SUPPLY1) ||
(sig->type() == NetNet::TRI1)) {
// Multiple drivers are not currently supported.
ivl_assert(*obj, val == verinum::Vz);
ivl_assert(*sig, val == verinum::Vz);
val = verinum::V1;
}
}
@ -222,13 +222,13 @@ verinum Nexus::driven_vector() const
if ((sig->type() == NetNet::SUPPLY0) ||
(sig->type() == NetNet::TRI0)) {
// Multiple drivers are not currently supported.
ivl_assert(*obj, val.len() == 0);
ivl_assert(*sig, val.len() == 0);
val = verinum(verinum::V0, width);
}
if ((sig->type() == NetNet::SUPPLY1) ||
(sig->type() == NetNet::TRI1)) {
// Multiple drivers are not currently supported.
ivl_assert(*obj, val.len() == 0);
ivl_assert(*sig, val.len() == 0);
val = verinum(verinum::V1, width);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2015 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -890,8 +890,8 @@ void Design::add_node(NetNode*net)
void Design::del_node(NetNode*net)
{
assert(net->design_ == this);
assert(net != 0);
assert(net->design_ == this);
/* Interact with the Design::functor method by manipulating the
cur and nxt pointers that it is using. */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2015 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -66,6 +66,7 @@ static bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
bool prefix_scope = false;
bool recurse_flag = false;
assert(li);
ivl_assert(*li, ! path.empty());
name_component_t path_tail = path.back();
path.pop_back();
@ -94,7 +95,7 @@ static bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
scope = recurse.scope;
prefix_scope = true;
if (scope->is_auto() && li) {
if (scope->is_auto()) {
cerr << li->get_fileline() << ": error: Hierarchical "
"reference to automatically allocated item "
"`" << path_tail.name << "' in path `" << path << "'" << endl;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2009-2015 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -29,10 +29,10 @@ static void run_string(const char*txt)
if (cp[0] == '%' && cp[1] != 0) {
switch (cp[1]) {
case 'M':
fprintf(stdout, "%u", VERSION_MAJOR);
fprintf(stdout, "%d", VERSION_MAJOR);
break;
case 'n':
fprintf(stdout, "%u", VERSION_MINOR);
fprintf(stdout, "%d", VERSION_MINOR);
break;
case 'E':
fprintf(stdout, "%s", VERSION_EXTRA);