From 4b114ff783bd98c08cffb6692b60c86e3bc2d57b Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 16 Jan 2009 16:46:11 -0800 Subject: [PATCH] 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. --- vpi/sys_fileio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index 7d4523e08..82a11c337 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -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; }