From 5cec7e38703c9f3c3193f6b7c7e4c5e30c482fb2 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 17 Jan 2011 17:42:45 -0800 Subject: [PATCH] Remove some cppcheck warnings about variable scope. There were a couple variable that could have reduced scope. --- tgt-vlog95/expr.c | 3 ++- tgt-vlog95/misc.c | 3 +-- tgt-vlog95/stmt.c | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tgt-vlog95/expr.c b/tgt-vlog95/expr.c index 2d7be3884..1710bcad7 100644 --- a/tgt-vlog95/expr.c +++ b/tgt-vlog95/expr.c @@ -247,9 +247,10 @@ static void emit_expr_select(ivl_scope_t scope, ivl_expr_t expr, unsigned wid) */ static void emit_expr_func(ivl_scope_t scope, ivl_expr_t expr, const char* name) { - unsigned idx, count = ivl_expr_parms(expr); + unsigned count = ivl_expr_parms(expr); fprintf(vlog_out, "%s", name); if (count != 0) { + unsigned idx; fprintf(vlog_out, "("); count -= 1; for (idx = 0; idx < count; idx += 1) { diff --git a/tgt-vlog95/misc.c b/tgt-vlog95/misc.c index 87cddaa7f..905493574 100644 --- a/tgt-vlog95/misc.c +++ b/tgt-vlog95/misc.c @@ -89,11 +89,10 @@ void emit_scaled_delayx(ivl_scope_t scope, ivl_expr_t expr) emit_scaled_delay(scope, value); } else { int exp = ivl_scope_time_units(scope) - sim_precision; - uint64_t scale = 1; assert(exp >= 0); if (exp == 0) emit_expr(scope, expr, 0); else { - uint64_t scale_val; + uint64_t scale_val, scale = 1; int rtype; /* This is as easy as removing the multiple that was * added to scale the value to the simulation time, diff --git a/tgt-vlog95/stmt.c b/tgt-vlog95/stmt.c index 366a60550..502a5a327 100644 --- a/tgt-vlog95/stmt.c +++ b/tgt-vlog95/stmt.c @@ -111,10 +111,10 @@ static void emit_stmt_lval_piece(ivl_scope_t scope, ivl_lval_t lval) static unsigned emit_stmt_lval(ivl_scope_t scope, ivl_statement_t stmt) { - unsigned idx; unsigned count = ivl_stmt_lvals(stmt); unsigned wid = 0; if (count > 1) { + unsigned idx; ivl_lval_t lval = ivl_stmt_lval(stmt, 0); wid += ivl_lval_width(lval); fprintf(vlog_out, "{"); @@ -399,9 +399,10 @@ static void emit_stmt_repeat(ivl_scope_t scope, ivl_statement_t stmt) static void emit_stmt_stask(ivl_scope_t scope, ivl_statement_t stmt) { - unsigned idx, count = ivl_stmt_parm_count(stmt); + unsigned count = ivl_stmt_parm_count(stmt); fprintf(vlog_out, "%*c%s", get_indent(), ' ', ivl_stmt_name(stmt)); if (count != 0) { + unsigned idx; fprintf(vlog_out, "("); count -= 1; for (idx = 0; idx < count; idx += 1) {