From 0e4dfa67323b04365d566481badfc1c7df15b61d Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 19 Aug 2015 11:14:23 -0700 Subject: [PATCH] Fix some compile warnings when using more modern compilers --- lexor.lex | 2 ++ vpi/lxt2_write.c | 6 ++++-- vpi/sys_lxt.c | 26 ++++++++------------------ vpi/sys_lxt2.c | 26 ++++++++------------------ vpi/sys_random.c | 2 +- vpi/sys_readmem.c | 13 ------------- vvp/codes.h | 2 +- vvp/draw_tt.c | 2 +- vvp/lexor.lex | 3 +++ vvp/vpip_to_dec.cc | 6 +----- 10 files changed, 29 insertions(+), 59 deletions(-) diff --git a/lexor.lex b/lexor.lex index 738f3ff1b..8b157c328 100644 --- a/lexor.lex +++ b/lexor.lex @@ -39,6 +39,8 @@ # define YY_USER_INIT reset_lexor(); # define yylval VLlval +#define YY_NO_INPUT + /* * Lexical location information is passed in the yylloc variable to th * parser. The file names, strings, are kept in a list so that I can diff --git a/vpi/lxt2_write.c b/vpi/lxt2_write.c index 94dff12b2..d42a1e2a9 100644 --- a/vpi/lxt2_write.c +++ b/vpi/lxt2_write.c @@ -1005,8 +1005,10 @@ for(cnt = 0; cnt < lt->break_header_size; cnt += sizeof(buf)) seg = sizeof(buf); } - fread(buf, seg, 1, clone); - fwrite(buf, seg, 1, f2); + if(fread(buf, seg, 1, clone)) + { + if(!fwrite(buf, seg, 1, f2)) break; /* write error! */ + } } fclose(clone); diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index 4ab85e6c4..d09426b20 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -476,7 +476,6 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) struct t_cb_data cb; struct vcd_info* info; - const char* type; const char* name; const char* ident; int nexus_id; @@ -507,10 +506,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) /* There is nothing in named events to dump. */ break; - case vpiNet: type = "wire"; if(0){ + case vpiNet: case vpiIntegerVar: case vpiTimeVar: - case vpiReg: type = "reg"; } + case vpiReg: if (skip) break; @@ -590,11 +589,11 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) break; - case vpiModule: type = "module"; if(0){ - case vpiNamedBegin: type = "begin"; }if(0){ - case vpiTask: type = "task"; }if(0){ - case vpiFunction: type = "function"; }if(0){ - case vpiNamedFork: type = "fork"; } + case vpiModule: + case vpiNamedBegin: + case vpiTask: + case vpiFunction: + case vpiNamedFork: if (depth > 0) { int nskip; @@ -648,7 +647,6 @@ static int draw_scope(vpiHandle item) { int depth; const char *name; - char *type; vpiHandle scope = vpi_handle(vpiScope, item); if (!scope) @@ -657,15 +655,7 @@ static int draw_scope(vpiHandle item) depth = 1 + draw_scope(scope); name = vpi_get_str(vpiName, scope); - switch (vpi_get(vpiType, item)) { - case vpiNamedBegin: type = "begin"; break; - case vpiTask: type = "task"; break; - case vpiFunction: type = "function"; break; - case vpiNamedFork: type = "fork"; break; - default: type = "module"; break; - } - - push_scope(name); /* keep in type info determination for possible future usage */ + push_scope(name); return depth; } diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index 95d8a5760..f8eca9e36 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -487,7 +487,6 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) struct t_cb_data cb; struct vcd_info* info; - const char* type; const char* name; const char* ident; int nexus_id; @@ -518,10 +517,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) /* There is nothing in named events to dump. */ break; - case vpiNet: type = "wire"; if(0){ + case vpiNet: case vpiIntegerVar: case vpiTimeVar: - case vpiReg: type = "reg"; } + case vpiReg: if (skip) break; @@ -608,11 +607,11 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) break; - case vpiModule: type = "module"; if(0){ - case vpiNamedBegin: type = "begin"; }if(0){ - case vpiTask: type = "task"; }if(0){ - case vpiFunction: type = "function"; }if(0){ - case vpiNamedFork: type = "fork"; } + case vpiModule: + case vpiNamedBegin: + case vpiTask: + case vpiFunction: + case vpiNamedFork: if (depth > 0) { int nskip; @@ -666,7 +665,6 @@ static int draw_scope(vpiHandle item) { int depth; const char *name; - char *type; vpiHandle scope = vpi_handle(vpiScope, item); if (!scope) @@ -675,15 +673,7 @@ static int draw_scope(vpiHandle item) depth = 1 + draw_scope(scope); name = vpi_get_str(vpiName, scope); - switch (vpi_get(vpiType, item)) { - case vpiNamedBegin: type = "begin"; break; - case vpiTask: type = "task"; break; - case vpiFunction: type = "function"; break; - case vpiNamedFork: type = "fork"; break; - default: type = "module"; break; - } - - push_scope(name); /* keep in type info determination for possible future usage */ + push_scope(name); return depth; } diff --git a/vpi/sys_random.c b/vpi/sys_random.c index 8098a3684..59cd6c2eb 100644 --- a/vpi/sys_random.c +++ b/vpi/sys_random.c @@ -49,7 +49,7 @@ long rtl_dist_poisson(long*seed, long mean) i = 0; } - return 0; + return i; } /* copied from IEEE1364-2001, with slight modifications for 64bit machines. */ diff --git a/vpi/sys_readmem.c b/vpi/sys_readmem.c index 2721f3c6c..200a8d1c1 100644 --- a/vpi/sys_readmem.c +++ b/vpi/sys_readmem.c @@ -354,14 +354,12 @@ static PLI_INT32 sys_readmem_calltf(char*name) static PLI_INT32 sys_writemem_calltf(char*name) { - int wwid; char*path; char*mem_name; FILE*file; unsigned addr = 0; unsigned cnt = 0; s_vpi_value value; - vpiHandle words; vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle item = vpi_scan(argv); @@ -374,7 +372,6 @@ static PLI_INT32 sys_writemem_calltf(char*name) int left_addr, right_addr; int start_addr, stop_addr, addr_incr; - int min_addr, max_addr; /*======================================== Get parameters */ @@ -493,9 +490,6 @@ static PLI_INT32 sys_writemem_calltf(char*name) } } - min_addr = start_addr # include + +# define YY_NO_INPUT + %} %% diff --git a/vvp/vpip_to_dec.cc b/vvp/vpip_to_dec.cc index e78666d55..ed659333d 100644 --- a/vvp/vpip_to_dec.cc +++ b/vvp/vpip_to_dec.cc @@ -108,7 +108,7 @@ static inline int write_digits(unsigned long v, char **buf, unsigned vpip_bits_to_dec_str(const unsigned char *bits, unsigned int nbits, char *buf, unsigned int nbuf, int signed_flag) { - unsigned int idx, len, vlen; + unsigned int idx, vlen; unsigned int mbits=nbits; /* number of non-sign bits */ unsigned count_x = 0, count_z = 0; /* Jump through some hoops so we don't have to malloc/free valv @@ -156,19 +156,15 @@ unsigned vpip_bits_to_dec_str(const unsigned char *bits, unsigned int nbits, } if (count_x == nbits) { - len = 1; buf[0] = 'x'; buf[1] = 0; } else if (count_x > 0) { - len = 1; buf[0] = 'X'; buf[1] = 0; } else if (count_z == nbits) { - len = 1; buf[0] = 'z'; buf[1] = 0; } else if (count_z > 0) { - len = 1; buf[0] = 'Z'; buf[1] = 0; } else {