From 614607c1357c86f2f4b44d076dac6c8f2f8c3cea Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 14 Jul 2026 01:30:05 -0700 Subject: [PATCH] Cppcheck fixes in vvp --- vvp/array.cc | 4 ++-- vvp/cppcheck.sup | 18 +++++++++--------- vvp/island_tran.cc | 4 ++-- vvp/vpi_darray.cc | 14 ++++---------- vvp/vpi_priv.cc | 2 +- vvp/vpi_priv.h | 3 +-- vvp/vthread.cc | 2 +- 7 files changed, 20 insertions(+), 27 deletions(-) diff --git a/vvp/array.cc b/vvp/array.cc index 2e9317b4d..98809adb8 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -162,7 +162,7 @@ int __vpiArray::get_word_size() const /* For a net array we need to get the width from the first element. */ if (nets) { assert(vals4 == 0 && vals == 0); - struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(nets[0]); + const struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(nets[0]); assert(vsig); width = vpip_size(vsig); /* For a variable array we can get the width from vals_width. */ @@ -625,7 +625,7 @@ void __vpiArray::set_word(unsigned address, unsigned part_off, const vvp_vector4 // Select the word of the array that we affect. vpiHandle word = nets[address]; - struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(word); + const struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(word); assert(vsig); vsig->node->send_vec4_pv(val, part_off, vpip_size(vsig), 0); diff --git a/vvp/cppcheck.sup b/vvp/cppcheck.sup index 128d0ab86..75f282368 100644 --- a/vvp/cppcheck.sup +++ b/vvp/cppcheck.sup @@ -92,11 +92,11 @@ knownConditionTrueFalse:vthread.cc:3571 duplicateExpression:vpi_signal.cc:1207 // cppcheck does not relize this is deleted[] in the called routine -leakNoVarFunctionCall:compile.cc:452 +leakNoVarFunctionCall:compile.cc:476 // Yes, these are not currently initialized in the constructor // All are added after __vpiSysTaskCall is built -uninitMemberVar:vpi_priv.h:946 +uninitMemberVar:vpi_priv.h:967 // All are added after __vpiSignal is built uninitMemberVar:vpi_priv.h:394 // run_run_ptr is added after the event is built @@ -151,13 +151,13 @@ knownConditionTrueFalse:vpi_modules.cc:118 redundantAssignment:vpi_modules.cc:117 // cppcheck does not undestand the format types match -invalidScanfArgType_int:compile.cc:597 -invalidScanfArgType_int:compile.cc:603 -invalidScanfArgType_int:compile.cc:609 -invalidScanfArgType_int:vthread.cc:4541 -invalidScanfArgType_int:vthread.cc:4544 -invalidScanfArgType_int:vthread.cc:4547 -invalidScanfArgType_int:vthread.cc:4550 +invalidScanfArgType_int:compile.cc:621 +invalidScanfArgType_int:compile.cc:627 +invalidScanfArgType_int:compile.cc:633 +invalidScanfArgType_int:vthread.cc:4580 +invalidScanfArgType_int:vthread.cc:4583 +invalidScanfArgType_int:vthread.cc:4586 +invalidScanfArgType_int:vthread.cc:4589 // The new() operator is always used to allocate space for this class and // pool is defined there. diff --git a/vvp/island_tran.cc b/vvp/island_tran.cc index 5e8c793a2..511527f7e 100644 --- a/vvp/island_tran.cc +++ b/vvp/island_tran.cc @@ -196,7 +196,7 @@ void vvp_island_tran::count_drivers(vvp_island_port*port, unsigned bit_idx, void vvp_island_branch_tran::run_test_enabled() { - vvp_island_port*ep = en? dynamic_cast (en->fun) : NULL; + const vvp_island_port*ep = en? dynamic_cast (en->fun) : NULL; // If there is no ep port (no "enabled" input) then this is a // tran branch. Assume it is always enabled. @@ -243,7 +243,7 @@ void vvp_island_branch_tran::run_test_enabled() bool vvp_island_branch_tran::rerun_test_enabled() { - vvp_island_port*ep = en? dynamic_cast (en->fun) : NULL; + const vvp_island_port*ep = en? dynamic_cast (en->fun) : NULL; if (ep == 0) return false; diff --git a/vvp/vpi_darray.cc b/vvp/vpi_darray.cc index 2ad9cb7d7..a81dcd6ba 100644 --- a/vvp/vpi_darray.cc +++ b/vvp/vpi_darray.cc @@ -309,12 +309,6 @@ int __vpiQueueVar::vpi_get(int code) } } -void __vpiQueueVar::vpi_get_value(p_vpi_value val) -{ - __vpiDarrayVar::vpi_get_value(val); -} - - vpiHandle vpip_make_queue_var(const char*name, vvp_net_t*net) { __vpiScope*scope = vpip_peek_current_scope(); @@ -337,7 +331,7 @@ int __vpiPropQueueRef::get_type_code(void) const static vvp_darray* get_live_darray_from_prop(vvp_net_t* class_net, unsigned pid) { if (!class_net) return 0; - vvp_fun_signal_object* fun = dynamic_cast(class_net->fun); + const vvp_fun_signal_object* fun = dynamic_cast(class_net->fun); if (!fun) return 0; vvp_object_t obj = fun->get_object(); vvp_cobject* cobj = obj.peek(); @@ -349,7 +343,7 @@ static vvp_darray* get_live_darray_from_prop(vvp_net_t* class_net, unsigned pid) int __vpiPropQueueRef::vpi_get(int code) { - vvp_darray* aobj = get_live_darray_from_prop(class_net_, prop_idx_); + const vvp_darray* aobj = get_live_darray_from_prop(class_net_, prop_idx_); switch (code) { case vpiArrayType: return is_queue_ ? vpiQueueArray : vpiDynamicArray; @@ -395,8 +389,8 @@ vvp_darray* vpip_vpi_darray_from_handle(vpiHandle ref) return get_live_darray_from_prop(pr->class_net_, pr->prop_idx_); } - if (__vpiDarrayVar* dv = dynamic_cast<__vpiDarrayVar*>(ref)) { - vvp_fun_signal_object* fun = dynamic_cast(dv->get_net()->fun); + if (const __vpiDarrayVar* dv = dynamic_cast<__vpiDarrayVar*>(ref)) { + const vvp_fun_signal_object* fun = dynamic_cast(dv->get_net()->fun); if (!fun) return 0; vvp_object_t obj = fun->get_object(); return obj.peek(); diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 1d84146b2..efcebe052 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -128,7 +128,7 @@ struct vpip_string_chunk { char data[64*1024 - sizeof (struct vpip_string_chunk*)]; }; -unsigned vpip_size(__vpiSignal *sig) +unsigned vpip_size(const __vpiSignal *sig) { return abs(sig->msb.get_value() - sig->lsb.get_value()) + 1; } diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 83fce94ce..b0fc1e322 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -396,7 +396,7 @@ struct __vpiSignal : public __vpiHandle { static void*operator new[] (std::size_t size); static void operator delete[](void*); }; -extern unsigned vpip_size(__vpiSignal *sig); +extern unsigned vpip_size(const __vpiSignal *sig); extern __vpiScope* vpip_scope(__vpiSignal*sig); extern vpiHandle vpip_make_int2(const char*name, int msb, int lsb, @@ -876,7 +876,6 @@ class __vpiQueueVar : public __vpiDarrayVar { __vpiQueueVar(__vpiScope*scope, const char*name, vvp_net_t*net); int vpi_get(int code) override; - void vpi_get_value(p_vpi_value val) override; }; extern vpiHandle vpip_make_queue_var(const char*name, vvp_net_t*net); diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 81989cb29..8aa011dad 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -6138,7 +6138,7 @@ bool of_PROP_QUEUE_SIZE(vthread_t thr, vvp_code_t cp) vvp_object_t qobj; cobj->get_object(pid, qobj, 0); - vvp_queue* queue = qobj.peek(); + const vvp_queue* queue = qobj.peek(); size_t sz = queue ? queue->get_size() : 0;