From f31a4e6d20cb03a87785ae72d994bca42a87ca29 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 10 Dec 2009 12:49:39 -0800 Subject: [PATCH] Add some casts in vpi to remove warnings. The Cygwin compiler is a bit picky. This patch adds some casts to remove compilation warnings. In the past I have had warnings off because of problems with the STL, but for C directories like this it makes sense to enable the warnings. It also does not recognize that an assert(0) or assert(false) ends a routine so it complains about no return at end of function or variables not being defined. --- vpi/sys_display.c | 7 ++++--- vpi/sys_fileio.c | 42 ++++++++++++++++++++--------------------- vpi/sys_readmem_lex.lex | 2 +- vpi/sys_scanf.c | 2 +- vpi/sys_vcd.c | 9 ++++++--- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 96cef1789..d463f0781 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -146,6 +146,7 @@ static int get_default_format(char *name) case 'o': default_format = vpiOctStrVal; break; case 'b': default_format = vpiBinStrVal; break; default: + default_format = -1; assert(0); } @@ -1139,7 +1140,7 @@ static PLI_INT32 sys_display_calltf(PLI_BYTE8 *name) vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("invalid file descriptor/MCD (0x%x) given " - "to %s.\n", fd_mcd, name); + "to %s.\n", (unsigned int)fd_mcd, name); errno = EBADF; vpi_free_object(argv); return 0; @@ -1259,7 +1260,7 @@ static PLI_INT32 sys_strobe_calltf(PLI_BYTE8*name) vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("invalid file descriptor/MCD (0x%x) given " - "to %s.\n", fd_mcd, name); + "to %s.\n", (unsigned int)fd_mcd, name); errno = EBADF; vpi_free_object(argv); return 0; @@ -1776,7 +1777,7 @@ static char *pts_convert(int value) case -13: string = "100fs"; break; case -14: string = "10fs"; break; case -15: string = "1fs"; break; - default: assert(0); + default: string = "invalid"; assert(0); } return string; } diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index 9961d95b6..938dee292 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -229,7 +229,7 @@ static PLI_INT32 sys_fclose_calltf(PLI_BYTE8*name) vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("invalid file descriptor/MCD (0x%x) given to %s.\n", - fd_mcd, name); + (unsigned int)fd_mcd, name); errno = EBADF; return 0; } @@ -277,7 +277,7 @@ static PLI_INT32 sys_fflush_calltf(PLI_BYTE8*name) vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("invalid file descriptor/MCD (0x%x) given to %s.\n", - fd_mcd, name); + (unsigned int)fd_mcd, name); errno = EBADF; return 0; } @@ -324,8 +324,8 @@ static PLI_INT32 sys_fputc_calltf(PLI_BYTE8*name) if (!fp) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("invalid file descriptor (0x%x) given to %s.\n", fd_mcd, - name); + vpi_printf("invalid file descriptor (0x%x) given to %s.\n", + (unsigned int)fd_mcd, name); errno = EBADF; val.value.integer = EOF; } else { @@ -412,8 +412,8 @@ static PLI_INT32 sys_fgets_calltf(PLI_BYTE8*name) if (!fp) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("invalid file descriptor (0x%x) given to %s.\n", fd_mcd, - name); + vpi_printf("invalid file descriptor (0x%x) given to %s.\n", + (unsigned int)fd_mcd, name); errno = EBADF; val.format = vpiIntVal; val.value.integer = 0; @@ -600,8 +600,8 @@ static PLI_INT32 sys_fread_calltf(PLI_BYTE8*name) if (!fp) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("invalid file descriptor (0x%x) given to %s.\n", fd_mcd, - name); + vpi_printf("invalid file descriptor (0x%x) given to %s.\n", + (unsigned int)fd_mcd, name); errno = EBADF; val.format = vpiIntVal; val.value.integer = 0; @@ -639,8 +639,8 @@ static PLI_INT32 sys_fread_calltf(PLI_BYTE8*name) vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("%s's start argument (%d) is outside " - "memory range [%d:%d].\n", name, start, - left, right); + "memory range [%d:%d].\n", name, (int)start, + (int)left, (int)right); val.format = vpiIntVal; val.value.integer = 0; vpi_put_value(callh, &val, 0, vpiNoDelay); @@ -660,8 +660,8 @@ static PLI_INT32 sys_fread_calltf(PLI_BYTE8*name) (int)vpi_get(vpiLineNo, callh)); vpi_printf("%s's count argument (%d) is too " "large for start (%d) and memory " - "range [%d:%d].\n", name, count, - start, left, right); + "range [%d:%d].\n", name, (int)count, + (int)start, (int)left, (int)right); count = max - start + 1; } vpi_free_object(argv); @@ -734,8 +734,8 @@ static PLI_INT32 sys_ungetc_calltf(PLI_BYTE8*name) if (!fp) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("invalid file descriptor (0x%x) given to %s.\n", fd_mcd, - name); + vpi_printf("invalid file descriptor (0x%x) given to %s.\n", + (unsigned int)fd_mcd, name); errno = EBADF; val.format = vpiIntVal; val.value.integer = EOF; @@ -860,7 +860,7 @@ static PLI_INT32 sys_fseek_calltf(PLI_BYTE8*name) vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("%s's operation must be 0, 1 or 2 given %d.\n", - name, oper); + name, (int)oper); oper = -1; /* An invalid argument value. */ } @@ -869,8 +869,8 @@ static PLI_INT32 sys_fseek_calltf(PLI_BYTE8*name) if (!fp) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("invalid file descriptor (0x%x) given to %s.\n", fd_mcd, - name); + vpi_printf("invalid file descriptor (0x%x) given to %s.\n", + (unsigned int)fd_mcd, name); errno = EBADF; val.format = vpiIntVal; val.value.integer = EOF; @@ -907,8 +907,8 @@ static PLI_INT32 sys_common_fd_calltf(PLI_BYTE8*name) if (!fp) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("invalid file descriptor (0x%x) given to %s.\n", fd_mcd, - name); + vpi_printf("invalid file descriptor (0x%x) given to %s.\n", + (unsigned int)fd_mcd, name); errno = EBADF; val.format = vpiIntVal; val.value.integer = EOF; @@ -1032,8 +1032,8 @@ static PLI_INT32 sys_ferror_calltf(PLI_BYTE8 *name) if (!errno && !vpi_get_file(fd_mcd) ) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("invalid file descriptor (0x%x) given to %s.\n", fd_mcd, - name); + vpi_printf("invalid file descriptor (0x%x) given to %s.\n", + (unsigned int)fd_mcd, name); errno = EBADF; } diff --git a/vpi/sys_readmem_lex.lex b/vpi/sys_readmem_lex.lex index e17ede241..9454b2cfb 100644 --- a/vpi/sys_readmem_lex.lex +++ b/vpi/sys_readmem_lex.lex @@ -62,7 +62,7 @@ static struct t_vpi_vecval*vecval = 0; static void make_addr() { - sscanf(yytext+1, "%x", &vecval->aval); + sscanf(yytext+1, "%x", (unsigned int*)&vecval->aval); } static void make_hex_value() diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index e36ddcfa5..f87780140 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -650,7 +650,7 @@ static PLI_INT32 sys_fscanf_calltf(PLI_BYTE8*name) vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("invalid file descriptor (0x%x) given to %s.\n", - val.value.integer, name); + (int)val.value.integer, name); errno = EBADF; val.format = vpiIntVal; val.value.integer = EOF; diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 53f24e48c..10465c668 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -667,8 +667,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) /* Add a range for vectored values. */ if (vpi_get(vpiSize, item) > 1 || vpi_get(vpiLeftRange, item) != 0) { - fprintf(dump_file, " [%i:%i]", vpi_get(vpiLeftRange, item), - vpi_get(vpiRightRange, item)); + fprintf(dump_file, " [%i:%i]", + (int)vpi_get(vpiLeftRange, item), + (int)vpi_get(vpiRightRange, item)); } fprintf(dump_file, " $end\n"); @@ -730,9 +731,11 @@ static int draw_scope(vpiHandle item, vpiHandle callh) case vpiNamedFork: type = "fork"; break; case vpiModule: type = "module"; break; default: + type = "invalid"; vpi_printf("VCD Error: %s:%d: $dumpvars: Unsupported scope " "type (%d)\n", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh), vpi_get(vpiType, item)); + (int)vpi_get(vpiLineNo, callh), + (int)vpi_get(vpiType, item)); assert(0); }