Fix for add valid FD/MCD check to $fflush and $fclose.

This patch fixes some issues in the previous patch. Specifically
I need to use vpi_mcd_printf and some trickery was needed to
prevent the compiler from complaining about the format string.
This commit is contained in:
Cary R 2009-01-16 16:46:11 -08:00 committed by Stephen Williams
parent c2d7ac61c2
commit 4b114ff783
1 changed files with 4 additions and 4 deletions

View File

@ -279,6 +279,7 @@ static PLI_INT32 sys_fclose_calltf(PLI_BYTE8*name)
vpiHandle fd = vpi_scan(argv);
s_vpi_value val;
PLI_UINT32 fd_mcd;
char *str = ""; /* This prevents the compiler from complaining. */
vpi_free_object(argv);
@ -288,12 +289,11 @@ static PLI_INT32 sys_fclose_calltf(PLI_BYTE8*name)
fd_mcd = val.value.integer;
if ((! IS_MCD(fd_mcd) && vpi_get_file(fd_mcd) == NULL) ||
( IS_MCD(fd_mcd) && my_mcd_printf(fd_mcd, "") == EOF)) {
( IS_MCD(fd_mcd) && vpi_mcd_printf(fd_mcd, str) == EOF)) {
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);
vpi_free_object(argv);
return 0;
}
@ -314,6 +314,7 @@ static PLI_INT32 sys_fflush_calltf(PLI_BYTE8*name)
s_vpi_value val;
PLI_UINT32 fd_mcd;
FILE *fp;
char *str = ""; /* This prevents the compiler from complaining. */
/* If we have no argument then flush all the streams. */
if (argv == 0) {
@ -329,12 +330,11 @@ static PLI_INT32 sys_fflush_calltf(PLI_BYTE8*name)
fd_mcd = val.value.integer;
if ((! IS_MCD(fd_mcd) && vpi_get_file(fd_mcd) == NULL) ||
( IS_MCD(fd_mcd) && my_mcd_printf(fd_mcd, "") == EOF)) {
( IS_MCD(fd_mcd) && vpi_mcd_printf(fd_mcd, str) == EOF)) {
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);
vpi_free_object(argv);
return 0;
}