Skip to content

Commit 3a28970

Browse files
committed
cppcheck cleanup
1 parent 698857c commit 3a28970

11 files changed

Lines changed: 40 additions & 36 deletions

File tree

‎cppcheck.sup‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ nullPointerOutOfMemory
1010
ctuuninitvar:parse_misc.cc:61
1111

1212
// Skip strdup() not constant.
13-
constVariablePointer:main.cc:421
14-
constVariablePointer:main.cc:425
15-
constVariablePointer:main.cc:675
13+
constVariablePointer:main.cc:434
14+
constVariablePointer:main.cc:438
15+
constVariablePointer:main.cc:688
1616

1717
// const auto should be const
18-
constVariablePointer:elab_expr.cc:628
19-
constVariablePointer:elab_expr.cc:631
20-
constVariablePointer:elab_expr.cc:700
18+
constVariablePointer:elab_expr.cc:641
19+
constVariablePointer:elab_expr.cc:644
20+
constVariablePointer:elab_expr.cc:713
21+
constVariablePointer:elab_expr.cc:4296
22+
constVariablePointer:elab_lval.cc:1149
23+
constVariablePointer:elab_scope.cc:1538
24+
constVariablePointer:parse.y:5388
2125

2226
// The reference cannot be const since it is updated in the calling function.
2327
constParameterReference:net_udp.cc:37
@@ -36,23 +40,23 @@ uninitMemberVar:t-dll.cc:41
3640
uninitMemberVar:t-dll.cc:109
3741

3842
// By convention we put statics at the top scope.
39-
variableScope:pform.cc:3630
43+
variableScope:pform.cc:3634
4044

4145
// These are correct and are used to find the base (zero) pin.
42-
thisSubtraction:netlist.h:5370
43-
thisSubtraction:netlist.h:5379
46+
thisSubtraction:netlist.h:5384
47+
thisSubtraction:netlist.h:5393
4448

4549
// This is used when running a debugger
4650
// debugger_release
47-
knownConditionTrueFalse:main.cc:955
51+
knownConditionTrueFalse:main.cc:968
4852

4953
// These should be checked, but are not real issues
5054
knownConditionTrueFalse:elaborate.cc:8165
5155
knownConditionTrueFalse:elab_sig.cc:272
5256
knownConditionTrueFalse:elab_sig.cc:345
5357

5458
// Yes, it's a duplicate
55-
duplicateCondition:elaborate.cc:8216
59+
duplicateCondition:elaborate.cc:8288
5660

5761
// To complicated to use std::find_if()
5862
useStlAlgorithm:map_named_args.cc:38
@@ -718,11 +722,11 @@ unusedFunction:t-dll-api.cc:980
718722
// has_compat_attributes()
719723
unusedFunction:Attrib.cc:72
720724
// bl_type()
721-
unusedFunction:Statement.h:194
725+
unusedFunction:Statement.h:193
722726
// chain_args()
723-
unusedFunction:Statement.h:369
727+
unusedFunction:Statement.h:370
724728
// gn_modules_nest()
725-
unusedFunction:compiler.h:247
729+
unusedFunction:compiler.h:250
726730
// driven_mask()
727731
unusedFunction:link_const.cc:275
728732
// find_root_scope()
@@ -732,9 +736,9 @@ unusedFunction:net_link.cc:283
732736
// intersect()
733737
unusedFunction:net_link.cc:687
734738
// get_def_fileline()
735-
unusedFunction:net_scope.cc:200
739+
unusedFunction:net_scope.cc:203
736740
// get_module_port_info()
737-
unusedFunction:net_scope.cc:631
741+
unusedFunction:net_scope.cc:683
738742
// find_link_signal()
739743
unusedFunction:netlist.cc:113
740744
// find_link()

‎driver/cppcheck.sup‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// cppcheck is wrong this is correct usage
2-
syntaxError:main.c:415
3-
syntaxError:main.c:412
2+
syntaxError:main.c:416
3+
syntaxError:main.c:413
44

55
// cppcheck is missing the code adds a \0 at the previous location.
66
knownConditionTrueFalse:main.c:1123

‎elab_expr.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6544,7 +6544,7 @@ NetExpr* PEIdent::elaborate_expr_param_uarray_(Design*des, NetScope*scope,
65446544
long mink = (lo <= hi) ? lo : hi;
65456545
long maxk = (lo <= hi) ? hi : lo;
65466546

6547-
if (NetEConst*idx_c = dynamic_cast<NetEConst*>(idx)) {
6547+
if (const NetEConst*idx_c = dynamic_cast<NetEConst*>(idx)) {
65486548
if (!idx_c->value().is_defined()) {
65496549
out_of_bounds = true;
65506550
} else {

‎elab_scope.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static void blend_class_constructors(PClass*pclass)
477477

478478
static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
479479
{
480-
class_type_t*use_type = pclass->type;
480+
const class_type_t*use_type = pclass->type;
481481

482482
if (debug_scopes) {
483483
cerr << pclass->get_fileline() <<": elaborate_scope_class: "

‎elaborate.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4635,19 +4635,19 @@ bool PCallTask::test_task_calls_ok_(Design*des, const NetScope*scope) const
46354635
}
46364636

46374637
NetProc *PCallTask::elaborate_non_void_function_(Design *des, NetScope *scope,
4638-
const pform_name_t &path) const
4638+
const pform_name_t &cpath) const
46394639
{
46404640
// Generate a function call version of this task call.
46414641
pform_scoped_name_t call_path = path_;
4642-
call_path.name = path;
4642+
call_path.name = cpath;
46434643
auto rval = new PECallFunction(call_path, parms_);
46444644
rval->set_line(*this);
46454645
// Generate an assign to nothing.
46464646
auto tmp = new PAssign(nullptr, rval);
46474647
tmp->set_line(*this);
46484648
if (!void_cast_) {
46494649
cerr << get_fileline() << ": warning: User function '"
4650-
<< peek_tail_name(path) << "' is being called as a task." << endl;
4650+
<< peek_tail_name(cpath) << "' is being called as a task." << endl;
46514651
}
46524652

46534653
// Elaborate the assignment to a dummy variable.

‎net_scope.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ void NetScope::add_typedefs(const map<perm_string,typedef_t*>*typedefs)
248248
typedef_t *NetScope::lookup_typedef(perm_string name,
249249
unsigned int lexical_pos) const
250250
{
251-
auto type = typedefs_.find(name);
252-
if (type == typedefs_.end())
251+
auto typed = typedefs_.find(name);
252+
if (typed == typedefs_.end())
253253
return nullptr;
254254

255-
if (type->second->lexical_pos() > lexical_pos)
255+
if (typed->second->lexical_pos() > lexical_pos)
256256
return nullptr;
257257

258-
return type->second;
258+
return typed->second;
259259
}
260260

261261
void NetScope::add_gate_names(const list<PGate*>&gates)

‎netclass.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef IVL_netclass_H
22
#define IVL_netclass_H
33
/*
4-
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
4+
* Copyright (c) 2012-2026 Stephen Williams (steve@icarus.com)
55
*
66
* This source code is free software; you can redistribute it
77
* and/or modify it in source code form under the terms of the GNU
@@ -35,7 +35,7 @@ class PExpr;
3535

3636
class netclass_t : public ivl_type_s {
3737
public:
38-
netclass_t(perm_string class_name);
38+
explicit netclass_t(perm_string class_name);
3939
~netclass_t() override;
4040

4141
// Set the property of the class during elaboration. Set the

‎netmisc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static inline bool test_function_return_value(const symbol_search_results&search
152152
}
153153

154154
extern bool symbol_search(const LineInfo *li, Design *des, NetScope *scope,
155-
pform_name_t path, unsigned int lexical_pos,
155+
const pform_name_t &path, unsigned int lexical_pos,
156156
struct symbol_search_results *res,
157157
unsigned int flags = 0);
158158

‎parse.y‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5385,7 +5385,7 @@ list_of_port_declarations
53855385
{ auto ports = $1;
53865386

53875387
Module::port_t*port;
5388-
auto previous_port = ports->back();
5388+
const auto previous_port = ports->back();
53895389
if (!$4.type && !$5 && previous_port &&
53905390
previous_port->is_interface_port()) {
53915391
// Inherit the interface header, but not unpacked dimensions.

‎symbol_search.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ static bool symbol_search_(const LineInfo *li, Design *des, NetScope *scope,
546546
const bool is_design_unit =
547547
(scope->type() == NetScope::MODULE && !scope->nested_module())
548548
|| scope->type() == NetScope::PACKAGE;
549-
if (!scope_is_bound && !searched_unit_scope && is_design_unit
550-
&& unit_scope && scope != unit_scope) {
549+
if (!searched_unit_scope && is_design_unit &&
550+
unit_scope && scope != unit_scope) {
551551
instance_parent = scope->parent();
552552
scope = unit_scope;
553553
searched_unit_scope = true;
@@ -611,7 +611,7 @@ static bool symbol_search_(const LineInfo *li, Design *des, NetScope *scope,
611611
}
612612

613613
bool symbol_search(const LineInfo *li, Design *des, NetScope *scope,
614-
pform_name_t path, unsigned int lexical_pos,
614+
const pform_name_t &path, unsigned int lexical_pos,
615615
struct symbol_search_results *res, unsigned int flags)
616616
{
617617
const bool allow_forward_reference =

0 commit comments

Comments
 (0)