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.
This commit is contained in:
Cary R 2009-12-10 12:49:39 -08:00 committed by Stephen Williams
parent d6246cf041
commit f31a4e6d20
5 changed files with 33 additions and 29 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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()

View File

@ -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;

View File

@ -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);
}