Fix a few more cppcheck issues.

Here are some more cleanups recommended by cppcheck. Mostly fixing the
variable scope and removing some unneeded code.
This commit is contained in:
Cary R 2010-04-19 10:25:42 -07:00 committed by Stephen Williams
parent e269a2f23c
commit b91657dbb9
9 changed files with 17 additions and 29 deletions

View File

@ -1308,7 +1308,7 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s
// passed. It is built up by the ordered overrides or named
// overrides.
typedef map<perm_string,PExpr*>::const_iterator mparm_it_t;
typedef map<perm_string,PExpr*>::const_iterator mparm_local_it_t;
map<perm_string,PExpr*> replace;
@ -1351,7 +1351,7 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s
// the expression in my context, then replace the sub-scope
// parameter value with the new expression.
for (mparm_it_t cur = replace.begin()
for (mparm_local_it_t cur = replace.begin()
; cur != replace.end() ; cur ++ ) {
PExpr*tmp = (*cur).second;

View File

@ -1441,14 +1441,6 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
if (instance.size() == 1 && sig->vector_width() < ccount)
ccount = sig->vector_width();
// The spin_modulus is the width of the signal (not the
// port) if this is an instance array. This causes
// signals wide enough for a single instance to be
// connected to all the instances.
unsigned spin_modulus = prts_vector_width;
if (instance.size() != 1)
spin_modulus = sig->vector_width();
// Now scan the concatenation that makes up the port,
// connecting pins until we run out of port pins or sig
// pins. The sig object is the NetNet that is connected

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2009 Michael Ruff (mruff at chiaro.com)
* Copyright (c) 2002-2010 Michael Ruff (mruff at chiaro.com)
* Michael Runyan (mrunyan at chiaro.com)
*
* This source code is free software; you can redistribute it
@ -185,7 +185,6 @@ static PLI_INT32 compiletf(char *data)
s_cb_data cb_data;
vpiHandle call_h, arg_i, arg_h;
p_pli_data dp;
int paramvc = 1;
int rtn = 0;
/* cast back from opaque */
@ -217,6 +216,7 @@ static PLI_INT32 compiletf(char *data)
functions get value change callbacks, controlled by the
tf_asyncon and tf_asyncoff functions. */
if (tf->misctf && ((arg_i = vpi_iterate(vpiArgument, call_h)) != NULL)) {
int paramvc = 1;
cb_data.reason = cbValueChange;
while ((arg_h = vpi_scan(arg_i)) != NULL) {

View File

@ -1646,7 +1646,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp,
static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid,
int stuff_ok_flag)
{
unsigned off, rep, expr_wid, concat_wid, num_sube, idx;
unsigned rep, expr_wid, concat_wid, num_sube, idx;
struct vector_info res;
int alloc_exclusive = (stuff_ok_flag&STUFF_OK_RO) ? 0 : 1;
@ -1685,7 +1685,7 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid,
/* If the result is the right size we can just build this in place. */
concat_wid = rep*expr_wid;
if (concat_wid <= wid) {
off = 0;
unsigned off = 0;
/* Evaluate the base expression. */
for (idx = num_sube; idx > 0; idx -= 1) {
ivl_expr_t arg = ivl_expr_parm(exp, idx-1);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2010 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
@ -282,15 +282,12 @@ static int compare_exp(ivl_expr_t l, ivl_expr_t r)
static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid)
{
unsigned top;
unsigned idx, match;
ivl_signal_t sig;
if (lookaside_top <= wid)
return 0;
top = lookaside_top - wid + 1;
/* Look in the expression lookaside for this expression. */
assert(exp);
match = 0;
@ -374,4 +371,3 @@ unsigned allocate_vector_exp(ivl_expr_t exp, unsigned wid,
return la;
}

View File

@ -1190,8 +1190,6 @@ static PLI_INT32 sys_display_calltf(PLI_BYTE8 *name)
*/
static PLI_INT32 strobe_cb(p_cb_data cb)
{
char* result = NULL;
unsigned int size, location=0;
struct strobe_cb_info*info = (struct strobe_cb_info*)cb->user_data;
/* We really need to cancel any $fstrobe() calls for a file when it
@ -1199,6 +1197,8 @@ static PLI_INT32 strobe_cb(p_cb_data cb)
* Which has the same basic effect. */
if ((! IS_MCD(info->fd_mcd) && vpi_get_file(info->fd_mcd) != NULL) ||
( IS_MCD(info->fd_mcd) && my_mcd_printf(info->fd_mcd, "") != EOF)) {
char* result = NULL;
unsigned int size, location=0;
/* Because %u and %z may put embedded NULL characters into the
* returned string strlen() may not match the real size! */
result = get_display(&size, info);
@ -1212,12 +1212,12 @@ static PLI_INT32 strobe_cb(p_cb_data cb)
}
}
my_mcd_printf(info->fd_mcd, "\n");
free(result);
}
free(info->filename);
free(info->items);
free(info);
free(result);
return 0;
}

View File

@ -79,7 +79,6 @@ static PLI_INT32 sys_fopen_calltf(PLI_BYTE8*name)
s_vpi_value val;
int fail = 0;
char *mode_string = 0;
unsigned idx;
vpiHandle fileh = vpi_scan(argv);
char *fname;
vpiHandle mode = vpi_scan(argv);
@ -111,7 +110,7 @@ static PLI_INT32 sys_fopen_calltf(PLI_BYTE8*name)
free(esc_md);
fail = 1;
} else {
unsigned bin = 0, plus = 0;
unsigned bin = 0, plus = 0, idx;
switch (val.value.str[0]) {
case 'r':
case 'w':
@ -581,7 +580,7 @@ static PLI_INT32 sys_fread_calltf(PLI_BYTE8*name)
s_vpi_value val;
PLI_UINT32 fd_mcd;
PLI_INT32 start, count, width, rtn;
unsigned is_mem, idx, bpe, words;
unsigned is_mem, bpe, words;
FILE *fp;
s_vpi_vecval *vector;
errno = 0;
@ -685,6 +684,7 @@ static PLI_INT32 sys_fread_calltf(PLI_BYTE8*name)
bpe = (width+7)/8;
if (is_mem) {
unsigned idx;
rtn = 0;
for (idx = 0; idx < count; idx += 1) {
vpiHandle word;

View File

@ -630,7 +630,7 @@ static PLI_INT32 sys_urandom_range_calltf(PLI_BYTE8 *name)
{
vpiHandle callh, argv, maxval, minval;
s_vpi_value val;
unsigned long i_maxval, i_minval, tmp;
unsigned long i_maxval, i_minval;
/* Get the argument handles and convert them. */
callh = vpi_handle(vpiSysTfCall, 0);
@ -647,7 +647,7 @@ static PLI_INT32 sys_urandom_range_calltf(PLI_BYTE8 *name)
/* Swap the two arguments if they are out of order. */
if (i_minval > i_maxval) {
tmp = i_minval;
unsigned long tmp = i_minval;
i_minval = i_maxval;
i_maxval = tmp;
}

View File

@ -33,7 +33,6 @@ static PLI_INT32 sys_time_calltf(PLI_BYTE8*name)
vpiHandle mod;
int units, prec;
long scale;
long frac;
call_handle = vpi_handle(vpiSysTfCall, 0);
assert(call_handle);
@ -59,7 +58,8 @@ static PLI_INT32 sys_time_calltf(PLI_BYTE8*name)
}
assert(8*sizeof(long long) >= 64);
{ long long tmp_now = ((long long)now.high) << 32;
{ long frac;
long long tmp_now = ((long long)now.high) << 32;
tmp_now += (long long)now.low;
frac = tmp_now % (long long)scale;
tmp_now /= (long long)scale;