Cppcheck fixes in vvp

This commit is contained in:
Cary R 2026-07-14 01:30:05 -07:00
parent dec4e939f4
commit 614607c135
7 changed files with 20 additions and 27 deletions

View File

@ -162,7 +162,7 @@ int __vpiArray::get_word_size() const
/* For a net array we need to get the width from the first element. */ /* For a net array we need to get the width from the first element. */
if (nets) { if (nets) {
assert(vals4 == 0 && vals == 0); assert(vals4 == 0 && vals == 0);
struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(nets[0]); const struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(nets[0]);
assert(vsig); assert(vsig);
width = vpip_size(vsig); width = vpip_size(vsig);
/* For a variable array we can get the width from vals_width. */ /* 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. // Select the word of the array that we affect.
vpiHandle word = nets[address]; vpiHandle word = nets[address];
struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(word); const struct __vpiSignal*vsig = dynamic_cast<__vpiSignal*>(word);
assert(vsig); assert(vsig);
vsig->node->send_vec4_pv(val, part_off, vpip_size(vsig), 0); vsig->node->send_vec4_pv(val, part_off, vpip_size(vsig), 0);

View File

@ -92,11 +92,11 @@ knownConditionTrueFalse:vthread.cc:3571
duplicateExpression:vpi_signal.cc:1207 duplicateExpression:vpi_signal.cc:1207
// cppcheck does not relize this is deleted[] in the called routine // 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 // Yes, these are not currently initialized in the constructor
// All are added after __vpiSysTaskCall is built // All are added after __vpiSysTaskCall is built
uninitMemberVar:vpi_priv.h:946 uninitMemberVar:vpi_priv.h:967
// All are added after __vpiSignal is built // All are added after __vpiSignal is built
uninitMemberVar:vpi_priv.h:394 uninitMemberVar:vpi_priv.h:394
// run_run_ptr is added after the event is built // run_run_ptr is added after the event is built
@ -151,13 +151,13 @@ knownConditionTrueFalse:vpi_modules.cc:118
redundantAssignment:vpi_modules.cc:117 redundantAssignment:vpi_modules.cc:117
// cppcheck does not undestand the format types match // cppcheck does not undestand the format types match
invalidScanfArgType_int:compile.cc:597 invalidScanfArgType_int:compile.cc:621
invalidScanfArgType_int:compile.cc:603 invalidScanfArgType_int:compile.cc:627
invalidScanfArgType_int:compile.cc:609 invalidScanfArgType_int:compile.cc:633
invalidScanfArgType_int:vthread.cc:4541 invalidScanfArgType_int:vthread.cc:4580
invalidScanfArgType_int:vthread.cc:4544 invalidScanfArgType_int:vthread.cc:4583
invalidScanfArgType_int:vthread.cc:4547 invalidScanfArgType_int:vthread.cc:4586
invalidScanfArgType_int:vthread.cc:4550 invalidScanfArgType_int:vthread.cc:4589
// The new() operator is always used to allocate space for this class and // The new() operator is always used to allocate space for this class and
// pool is defined there. // pool is defined there.

View File

@ -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() void vvp_island_branch_tran::run_test_enabled()
{ {
vvp_island_port*ep = en? dynamic_cast<vvp_island_port*> (en->fun) : NULL; const vvp_island_port*ep = en? dynamic_cast<vvp_island_port*> (en->fun) : NULL;
// If there is no ep port (no "enabled" input) then this is a // If there is no ep port (no "enabled" input) then this is a
// tran branch. Assume it is always enabled. // 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() bool vvp_island_branch_tran::rerun_test_enabled()
{ {
vvp_island_port*ep = en? dynamic_cast<vvp_island_port*> (en->fun) : NULL; const vvp_island_port*ep = en? dynamic_cast<vvp_island_port*> (en->fun) : NULL;
if (ep == 0) if (ep == 0)
return false; return false;

View File

@ -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) vpiHandle vpip_make_queue_var(const char*name, vvp_net_t*net)
{ {
__vpiScope*scope = vpip_peek_current_scope(); __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) static vvp_darray* get_live_darray_from_prop(vvp_net_t* class_net, unsigned pid)
{ {
if (!class_net) return 0; if (!class_net) return 0;
vvp_fun_signal_object* fun = dynamic_cast<vvp_fun_signal_object*>(class_net->fun); const vvp_fun_signal_object* fun = dynamic_cast<vvp_fun_signal_object*>(class_net->fun);
if (!fun) return 0; if (!fun) return 0;
vvp_object_t obj = fun->get_object(); vvp_object_t obj = fun->get_object();
vvp_cobject* cobj = obj.peek<vvp_cobject>(); vvp_cobject* cobj = obj.peek<vvp_cobject>();
@ -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) 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) { switch (code) {
case vpiArrayType: case vpiArrayType:
return is_queue_ ? vpiQueueArray : vpiDynamicArray; 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_); return get_live_darray_from_prop(pr->class_net_, pr->prop_idx_);
} }
if (__vpiDarrayVar* dv = dynamic_cast<__vpiDarrayVar*>(ref)) { if (const __vpiDarrayVar* dv = dynamic_cast<__vpiDarrayVar*>(ref)) {
vvp_fun_signal_object* fun = dynamic_cast<vvp_fun_signal_object*>(dv->get_net()->fun); const vvp_fun_signal_object* fun = dynamic_cast<vvp_fun_signal_object*>(dv->get_net()->fun);
if (!fun) return 0; if (!fun) return 0;
vvp_object_t obj = fun->get_object(); vvp_object_t obj = fun->get_object();
return obj.peek<vvp_darray>(); return obj.peek<vvp_darray>();

View File

@ -128,7 +128,7 @@ struct vpip_string_chunk {
char data[64*1024 - sizeof (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; return abs(sig->msb.get_value() - sig->lsb.get_value()) + 1;
} }

View File

@ -396,7 +396,7 @@ struct __vpiSignal : public __vpiHandle {
static void*operator new[] (std::size_t size); static void*operator new[] (std::size_t size);
static void operator delete[](void*); 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 __vpiScope* vpip_scope(__vpiSignal*sig);
extern vpiHandle vpip_make_int2(const char*name, int msb, int lsb, 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); __vpiQueueVar(__vpiScope*scope, const char*name, vvp_net_t*net);
int vpi_get(int code) override; 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); extern vpiHandle vpip_make_queue_var(const char*name, vvp_net_t*net);

View File

@ -6138,7 +6138,7 @@ bool of_PROP_QUEUE_SIZE(vthread_t thr, vvp_code_t cp)
vvp_object_t qobj; vvp_object_t qobj;
cobj->get_object(pid, qobj, 0); cobj->get_object(pid, qobj, 0);
vvp_queue* queue = qobj.peek<vvp_queue>(); const vvp_queue* queue = qobj.peek<vvp_queue>();
size_t sz = queue ? queue->get_size() : 0; size_t sz = queue ? queue->get_size() : 0;