From 1a82287f1e8eefa4245080b9d76b2099593dbe11 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 31 Aug 2012 12:11:06 -0700 Subject: [PATCH] Remove some cppcheck reduce scope warnings. --- libveriuser/a_handle_by_name.c | 5 ++--- libveriuser/a_handle_tfarg.c | 6 ++++-- libveriuser/veriusertfs.c | 5 ++--- vpi/sys_fileio.c | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libveriuser/a_handle_by_name.c b/libveriuser/a_handle_by_name.c index 8ad44fe04..c6a96c878 100644 --- a/libveriuser/a_handle_by_name.c +++ b/libveriuser/a_handle_by_name.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003 Michael Ruff (mruff at chiaro.com) + * Copyright (c) 2003-2012 Michael Ruff (mruff at chiaro.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -28,12 +28,11 @@ */ handle acc_handle_by_name(const char*obj_name, handle scope) { - vpiHandle sys_h; vpiHandle res; /* if no scope provided, use tasks scope */ if (!scope) { - sys_h = vpi_handle(vpiSysTfCall, 0 /* NULL */); + vpiHandle sys_h = vpi_handle(vpiSysTfCall, 0 /* NULL */); scope = vpi_handle(vpiScope, sys_h); } diff --git a/libveriuser/a_handle_tfarg.c b/libveriuser/a_handle_tfarg.c index df427b6ee..4f92116bf 100644 --- a/libveriuser/a_handle_tfarg.c +++ b/libveriuser/a_handle_tfarg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002 Michael Ruff (mruff at chiaro.com) + * Copyright (c) 2002-2012 Michael Ruff (mruff at chiaro.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -25,9 +25,11 @@ */ handle acc_handle_tfarg(int n) { - vpiHandle sys_h, sys_i, rtn_h = 0; + vpiHandle rtn_h = 0; if (n > 0) { + vpiHandle sys_h, sys_i; + sys_h = vpi_handle(vpiSysTfCall, 0 /* NULL */); sys_i = vpi_iterate(vpiArgument, sys_h); diff --git a/libveriuser/veriusertfs.c b/libveriuser/veriusertfs.c index 9c4703132..114dcf45d 100644 --- a/libveriuser/veriusertfs.c +++ b/libveriuser/veriusertfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2011 Michael Ruff (mruff at chiaro.com) + * Copyright (c) 2002-2012 Michael Ruff (mruff at chiaro.com) * Michael Runyan (mrunyan at chiaro.com) * * This source code is free software; you can redistribute it @@ -184,7 +184,6 @@ static PLI_INT32 compiletf(char *data) p_tfcell tf; s_cb_data cb_data; vpiHandle call_h, arg_i, arg_h; - p_pli_data dp; int rtn = 0; /* cast back from opaque */ @@ -221,7 +220,7 @@ static PLI_INT32 compiletf(char *data) cb_data.reason = cbValueChange; while ((arg_h = vpi_scan(arg_i)) != NULL) { /* replicate user_data for each instance */ - dp = calloc(1, sizeof(s_pli_data)); + p_pli_data dp = calloc(1, sizeof(s_pli_data)); memcpy(dp, cb_data.user_data, sizeof(s_pli_data)); dp->paramvc = paramvc++; cb_data.user_data = (char *)dp; diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index 64b3501e4..5feaa6699 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -252,7 +252,6 @@ static PLI_INT32 sys_fflush_calltf(ICARUS_VPI_CONST PLI_BYTE8*name) vpiHandle arg; s_vpi_value val; PLI_UINT32 fd_mcd; - FILE *fp; errno = 0; /* If we have no argument then flush all the streams. */ @@ -286,7 +285,7 @@ static PLI_INT32 sys_fflush_calltf(ICARUS_VPI_CONST PLI_BYTE8*name) vpi_mcd_flush(fd_mcd); } else { /* If we have a valid file descriptor flush the file. */ - fp = vpi_get_file(fd_mcd); + FILE *fp = vpi_get_file(fd_mcd); if (fp) fflush(fp); }