Clean up some more sign-compare issues
The only known problems left are in files imported from gtkwave, if not for them you could turn on -Wsign-compare. Assumes c99 for c code, so the scope of for-loop indexes can be made sane.
This commit is contained in:
parent
6101044bff
commit
642acb4082
|
|
@ -799,7 +799,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
int e_flag = 0;
|
||||
int version_flag = 0;
|
||||
int opt, idx;
|
||||
int opt;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
/* Calculate the ivl_root from the path to the command. This
|
||||
|
|
@ -1142,7 +1142,7 @@ int main(int argc, char **argv)
|
|||
vhdlpp_work = "ivl_vhdl_work";
|
||||
fprintf(defines_file, "vhdlpp:%s%cvhdlpp\n", vhdlpp_dir, sep);
|
||||
fprintf(defines_file, "vhdlpp-work:%s\n", vhdlpp_work);
|
||||
for (idx = 0 ; idx < vhdlpp_libdir_cnt ; idx += 1)
|
||||
for (unsigned idx = 0 ; idx < vhdlpp_libdir_cnt ; idx += 1)
|
||||
fprintf(defines_file, "vhdlpp-libdir:%s\n", vhdlpp_libdir[idx]);
|
||||
|
||||
/* Process parameter definition from command line. The last
|
||||
|
|
@ -1156,7 +1156,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* Finally, process all the remaining words on the command
|
||||
line as file names. */
|
||||
for (idx = optind ; idx < argc ; idx += 1)
|
||||
for (int idx = optind ; idx < argc ; idx += 1)
|
||||
process_file_name(argv[idx], 0);
|
||||
|
||||
/* If the use of a default include directory is not
|
||||
|
|
|
|||
|
|
@ -1634,7 +1634,8 @@ static const char* do_magic(const char*name)
|
|||
|
||||
int actual_len = snprintf(magic_text, desired_cnt,
|
||||
"%u", get_line(istack));
|
||||
assert(actual_len < desired_cnt);
|
||||
assert(actual_len >= 0);
|
||||
assert((unsigned) actual_len < desired_cnt);
|
||||
return magic_text;
|
||||
}
|
||||
else if(!strcmp(name, "__FILE__"))
|
||||
|
|
@ -1654,7 +1655,9 @@ static const char* do_magic(const char*name)
|
|||
|
||||
int actual_len = snprintf(magic_text, desired_cnt,
|
||||
"\"%s\"", path);
|
||||
assert(actual_len < desired_cnt);
|
||||
|
||||
assert(actual_len >= 0);
|
||||
assert((unsigned) actual_len < (unsigned)desired_cnt);
|
||||
return magic_text;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@
|
|||
|
||||
void show_class(ivl_type_t net)
|
||||
{
|
||||
unsigned idx;
|
||||
|
||||
fprintf(out, " class %s\n", ivl_type_name(net));
|
||||
for (idx = 0 ; idx < ivl_type_properties(net) ; idx += 1) {
|
||||
for (int idx = 0 ; idx < ivl_type_properties(net) ; idx += 1) {
|
||||
fprintf(out, " ");
|
||||
show_net_type(ivl_type_prop_type(net,idx));
|
||||
fprintf(out, " %s\n", ivl_type_prop_name(net,idx));
|
||||
|
|
|
|||
|
|
@ -75,11 +75,10 @@ static int32_t get_int32_from_bits(const char *bits, unsigned nbits,
|
|||
* otherwise emit them as a hex constant. */
|
||||
static void emit_bits(const char *bits, unsigned nbits, unsigned is_signed)
|
||||
{
|
||||
int idx;
|
||||
unsigned has_undef = 0;
|
||||
|
||||
/* Check for an undefined bit. */
|
||||
for (idx = (int)nbits-1; idx >= 0; idx -= 1) {
|
||||
for (int idx = (int)nbits-1; idx >= 0; idx -= 1) {
|
||||
if ((bits[idx] != '0') && (bits[idx] != '1')) {
|
||||
has_undef = 1;
|
||||
break;
|
||||
|
|
@ -92,23 +91,23 @@ static void emit_bits(const char *bits, unsigned nbits, unsigned is_signed)
|
|||
/* Emit as a binary constant. */
|
||||
if (has_undef || (nbits < 2)) {
|
||||
fprintf(vlog_out, "b");
|
||||
for (idx = (int)nbits-1; idx >= 0; idx -= 1) {
|
||||
for (int idx = (int)nbits-1; idx >= 0; idx -= 1) {
|
||||
fprintf(vlog_out, "%c", bits[idx]);
|
||||
}
|
||||
/* Emit as a hex constant. */
|
||||
} else {
|
||||
int start = 4*(nbits/4);
|
||||
unsigned start = 4*(nbits/4);
|
||||
unsigned result = 0;
|
||||
fprintf(vlog_out, "h");
|
||||
/* The first digit may not be a full hex digit. */
|
||||
if (start < nbits) {
|
||||
for (idx = start; idx < nbits; idx += 1) {
|
||||
for (unsigned idx = start; idx < nbits; idx += 1) {
|
||||
if (bits[idx] == '1') result |= 1U << (idx%4);
|
||||
}
|
||||
fprintf(vlog_out, "%1x", result);
|
||||
}
|
||||
/* Now print the full hex digits. */
|
||||
for (idx = start-1; idx >= 0; idx -= 4) {
|
||||
for (int idx = start-1; idx >= 0; idx -= 4) {
|
||||
result = 0;
|
||||
if (bits[idx] == '1') result |= 0x8;
|
||||
if (bits[idx-1] == '1') result |= 0x4;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ static void check_command_line_args(void)
|
|||
|
||||
vpi_get_vlog_info(&vlog_info);
|
||||
|
||||
for (unsigned idx = 0 ; idx < vlog_info.argc ; idx += 1) {
|
||||
for (int idx = 0 ; idx < vlog_info.argc ; idx += 1) {
|
||||
if (strcmp(vlog_info.argv[idx],"-compatible") == 0) {
|
||||
compatible_flag = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -822,6 +822,7 @@ static int scan_format_two_state(vpiHandle callh, vpiHandle argv,
|
|||
bits |= (ch & 0xff) << byte*8;
|
||||
}
|
||||
/* Only save the words that are in range. */
|
||||
assert(varlen>=0);
|
||||
if (word < (unsigned)varlen) {
|
||||
val_ptr[word].aval = bits;
|
||||
val_ptr[word].bval = 0;
|
||||
|
|
@ -836,8 +837,9 @@ static int scan_format_two_state(vpiHandle callh, vpiHandle argv,
|
|||
|
||||
/* Not enough words were read to fill the variable so zero fill the
|
||||
* upper words. */
|
||||
assert(varlen>=0);
|
||||
if (words < (unsigned)varlen) {
|
||||
for (word = words; word < varlen ; word += 1) {
|
||||
for (word = words; word < (unsigned)varlen ; word += 1) {
|
||||
val_ptr[word].aval = 0;
|
||||
val_ptr[word].bval = 0;
|
||||
}
|
||||
|
|
@ -978,8 +980,9 @@ static int scan_format_four_state(vpiHandle callh, vpiHandle argv,
|
|||
|
||||
/* Not enough words were read to fill the variable so zero fill the
|
||||
* upper words. */
|
||||
assert(varlen>=0);
|
||||
if (words < (unsigned)varlen) {
|
||||
for (word = words; word < varlen ; word += 1) {
|
||||
for (word = words; word < (unsigned)varlen ; word += 1) {
|
||||
val_ptr[word].aval = 0;
|
||||
val_ptr[word].bval = 0;
|
||||
}
|
||||
|
|
@ -1114,7 +1117,7 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv,
|
|||
|
||||
/* Read a '%' character from the input. */
|
||||
case '%':
|
||||
assert(max_width == -1);
|
||||
assert(max_width == -1U);
|
||||
assert(suppress_flag == 0);
|
||||
ch = byte_getc(src);
|
||||
if (ch != '%') {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ unsigned is_const_string_obj(vpiHandle arg)
|
|||
static void check_command_line_flags()
|
||||
{
|
||||
struct t_vpi_vlog_info vlog_info;
|
||||
unsigned idx;
|
||||
static unsigned command_line_processed = 0;
|
||||
|
||||
/* If we have already processed the arguments then just return. */
|
||||
|
|
@ -121,7 +120,7 @@ static void check_command_line_flags()
|
|||
|
||||
vpi_get_vlog_info(&vlog_info);
|
||||
|
||||
for (idx = 0; idx < vlog_info.argc; idx += 1) {
|
||||
for (int idx = 0; idx < vlog_info.argc; idx += 1) {
|
||||
if (strcmp(vlog_info.argv[idx], "-table-model-debug") == 0) {
|
||||
table_model_debug = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue