Fix some cppcheck warnings

This commit is contained in:
Cary R
2015-10-02 09:44:02 -07:00
parent 63d2059b85
commit 643e0a984e
12 changed files with 18 additions and 19 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2009 Stephen Williams ([email protected])
* Copyright (c) 2001-2015 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -63,7 +63,7 @@ static void draw_hex_table(void)
printf(" 'X',");
else
printf(" '%c',", "0123456789abcdef"[bv]);
printf(" '%c',", (unsigned)"0123456789abcdef"[bv]);
if (((idx+1) % 8) == 0)
printf("\n");
@@ -109,7 +109,7 @@ static void draw_oct_table(void)
printf(" 'X',");
else
printf(" '%c',", "01234567"[bv]);
printf(" '%c',", (unsigned)"01234567"[bv]);
if (((idx+1) % 8) == 0)
printf("\n");
+2 -2
View File
@@ -148,13 +148,13 @@ void verify_version(char*ivl_ver, char*commit)
// This also catches a potential new-new format that has
// another sub-minor number.
file_extra[0] = 0;
int rc = sscanf(ivl_ver, "%d.%d.%d %128s", &file_major, &file_minor, &file_minor2, file_extra);
int rc = sscanf(ivl_ver, "%d.%d.%d %127s", &file_major, &file_minor, &file_minor2, file_extra);
// If it wasn't the old style format, try the new format:
// <major>.<minor> <extra>
if (rc == 2) {
file_extra[0] = 0;
rc = sscanf(ivl_ver, "%d.%d %128s", &file_major, &file_minor, file_extra);
rc = sscanf(ivl_ver, "%d.%d %127s", &file_major, &file_minor, file_extra);
file_minor2 = 0;
}
+1 -1
View File
@@ -170,7 +170,6 @@ void __vpiDarrayVar::put_word_value(struct __vpiArrayWord*word, p_vpi_value vp,
case vpiVectorVal: // 2 vs 4 state logic?
{
int new_bit;
int size = get_word_size();
PLI_INT32 a = 0, b = 0;
vvp_vector4_t new_vec(size);
@@ -178,6 +177,7 @@ void __vpiDarrayVar::put_word_value(struct __vpiArrayWord*word, p_vpi_value vp,
vec--; // it will be increased in the first loop iteration
for(int i = 0; i < size; ++i) {
int new_bit;
if(i % (8 * sizeof(vec->aval)) == 0) {
++vec;
a = vec->aval;
+1 -1
View File
@@ -161,7 +161,7 @@ static unsigned hash_string(const char*text)
unsigned h = 0;
while (*text) {
h = (h << 4) ^ (h >> 28) ^ *text;
h = (h << 4) ^ (h >> 28) ^ (unsigned)*text;
text += 1;
}
return h;
+1 -1
View File
@@ -851,7 +851,7 @@ vvp_vector4_t vec4_from_vpi_value(s_vpi_value*vp, unsigned wid)
case vpiIntVal: {
long vpi_val = vp->value.integer;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
vvp_bit4_t bit = vpi_val&1 ? BIT4_1 : BIT4_0;
vvp_bit4_t bit = (vpi_val & 1) ? BIT4_1 : BIT4_0;
val.set_bit(idx, bit);
vpi_val >>= 1;
}
+1 -1
View File
@@ -153,7 +153,7 @@ static void timevar_get_value(vpiHandle ref, s_vpi_value*vp, bool is_int_func,
rbuf[num_bits] = 0;
for (unsigned i = 1; i <= num_bits; i++) {
rbuf[num_bits-i] = x & 1 ? '1' : '0';
rbuf[num_bits-i] = (x & 1) ? '1' : '0';
x = x >> 1;
}
+4 -4
View File
@@ -3585,10 +3585,10 @@ vvp_scalar_t fully_featured_resolv_(vvp_scalar_t a, vvp_scalar_t b)
has an even wider ambiguity. */
unsigned tmp = 0;
int sv1a = a.value_&0x80 ? STREN1(a.value_) : - STREN1(a.value_);
int sv0a = a.value_&0x08 ? STREN0(a.value_) : - STREN0(a.value_);
int sv1b = b.value_&0x80 ? STREN1(b.value_) : - STREN1(b.value_);
int sv0b = b.value_&0x08 ? STREN0(b.value_) : - STREN0(b.value_);
int sv1a = (a.value_ & 0x80) ? STREN1(a.value_) : - STREN1(a.value_);
int sv0a = (a.value_ & 0x08) ? STREN0(a.value_) : - STREN0(a.value_);
int sv1b = (b.value_ & 0x80) ? STREN1(b.value_) : - STREN1(b.value_);
int sv0b = (b.value_ & 0x08) ? STREN0(b.value_) : - STREN0(b.value_);
int sv1 = sv1a;
int sv0 = sv0a;