8000 fix more cppcheck errors (#18570) · xuyanshi/arangodb@58e9629 · GitHub
[go: up one dir, main page]

Skip to content

Commit 58e9629

Browse files
authored
fix more cppcheck errors (arangodb#18570)
1 parent 7f7c9a6 commit 58e9629

File tree

< 8000 div class="d-md-none">

10 files changed

+91
-94
lines changed

10 files changed

+91
-94
lines changed

arangod/RestHandler/RestGraphHandler.cpp

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Result RestGraphHandler::edgeSetsAction(Graph& graph) {
216216
}
217217

218218
Result RestGraphHandler::edgeSetAction(Graph& graph,
219-
const std::string& edgeDefinitionName) {
219+
std::string const& edgeDefinitionName) {
220220
switch (request()->requestType()) {
221221
case RequestType::POST:
222222
return edgeActionCreate(graph, edgeDefinitionName);
@@ -230,7 +230,7 @@ Result RestGraphHandler::edgeSetAction(Graph& graph,
230230
}
231231

232232
Result RestGraphHandler::vertexSetAction(
233-
Graph& graph, const std::string& vertexCollectionName) {
233+
Graph& graph, std::string const& vertexCollectionName) {
234234
switch (request()->requestType()) {
235235
case RequestType::POST:
236236
return vertexActionCreate(graph, vertexCollectionName);
@@ -243,8 +243,8 @@ Result RestGraphHandler::vertexSetAction(
243243
}
244244

245245
Result RestGraphHandler::vertexAction(Graph& graph,
246-
const std::string& vertexCollectionName,
247-
const std::string& vertexKey) {
246+
std::string const& vertexCollectionName,
247+
std::string const& vertexKey) {
248248
switch (request()->requestType()) {
249249
case RequestType::GET: {
250250
vertexActionRead(graph, vertexCollectionName, vertexKey);
@@ -262,8 +262,8 @@ Result RestGraphHandler::vertexAction(Graph& graph,
262262
}
263263

264264
Result RestGraphHandler::edgeAction(Graph& graph,
265-
const std::string& edgeDefinitionName,
266-
const std::string& edgeKey) {
265+
std::string const& edgeDefinitionName,
266+
std::string const& edgeKey) {
267267
switch (request()->requestType()) {
268268
case RequestType::GET:
269269
edgeActionRead(graph, edgeDefinitionName, edgeKey);
@@ -552,8 +552,8 @@ void RestGraphHandler::generateResultMergedWithObject(
552552

553553
// TODO this is nearly exactly the same as vertexActionRead. reuse somehow?
554554
void RestGraphHandler::edgeActionRead(Graph& graph,
555-
const std::string& definitionName,
556-
const std::string& key) {
555+
std::string const& definitionName,
556+
std::string const& key) {
557557
// check for an etag
558558
bool isValidRevision;
559559
RevisionId ifNoneRid = extractRevision("if-none-match", isValidRevision);
@@ -586,12 +586,13 @@ void RestGraphHandler::edgeActionRead(Graph& graph,
586586
}
587587

588588
std::unique_ptr<Graph> RestGraphHandler::getGraph(
589-
const std::string& graphName) {
589+
std::string const& graphName) {
590590
auto graphResult = _graphManager.lookupGraphByName(graphName);
591591
if (graphResult.fail()) {
592592
THROW_ARANGO_EXCEPTION(std::move(graphResult).result());
593593
}
594594
TRI_ASSERT(graphResult.get() != nullptr);
595+
// cppcheck-suppress returnStdMoveLocal
595596
return std::move(graphResult.get());
596597
}
597598

@@ -601,8 +602,8 @@ std::unique_ptr<Graph> RestGraphHandler::getGraph(
601602
// contains the old value in the field "old". This is not documented in
602603
// HTTP/Gharial!
603604
Result RestGraphHandler::edgeActionRemove(Graph& graph,
604-
const std::string& definitionName,
605-
const std::string& key) {
605+
std::string const& definitionName,
606+
std::string const& key) {
606607
bool waitForSync =
607608
_request->parsedValue(StaticStrings::WaitForSyncString, false);
608609

@@ -639,65 +640,65 @@ void RestGraphHandler::addEtagHeader(velocypack::Slice rev) {
639640
}
640641

641642
Result RestGraphHandler::vertexActionUpdate(graph::Graph& graph,
642-
const std::string& collectionName,
643-
const std::string& key) {
643+
std::string const& collectionName,
644+
std::string const& key) {
644645
return vertexModify(graph, collectionName, key, true);
645646
}
646647

647648
Result RestGraphHandler::vertexActionReplace(graph::Graph& graph,
648-
const std::string& collectionName,
649-
const std::string& key) {
649+
std::string const& collectionName,
650+
std::string const& key) {
650651
return vertexModify(graph, collectionName, key, false);
651652
}
652653

653654
Result RestGraphHandler::vertexActionCreate(graph::Graph& graph,
654-
const std::string& collectionName) {
655+
std::string const& collectionName) {
655656
return vertexCreate(graph, collectionName);
656657
}
657658

658659
Result RestGraphHandler::edgeActionUpdate(graph::Graph& graph,
659-
const std::string& collectionName,
660-
const std::string& key) {
660+
std::string const& collectionName,
661+
std::string const& key) {
661662
return edgeModify(graph, collectionName, key, true);
662663
}
663664

664665
Result RestGraphHandler::edgeActionReplace(graph::Graph& graph,
665-
const std::string& collectionName,
666-
const std::string& key) {
666+
std::string const& collectionName,
667+
std::string const& key) {
667668
return edgeModify(graph, collectionName, key, false);
668669
}
669670

670671
Result RestGraphHandler::edgeModify(graph::Graph& graph,
671-
const std::string& collectionName,
672-
const std::string& key, bool isPatch) {
672+
std::string const& collectionName,
673+
std::string const& key, bool isPatch) {
673674
return documentModify(graph, collectionName, key, isPatch, TRI_COL_TYPE_EDGE);
674675
}
675676

676677
Result RestGraphHandler::edgeCreate(graph::Graph& graph,
677-
const std::string& collectionName) {
678+
std::string const& collectionName) {
678679
return documentCreate(graph, collectionName, TRI_COL_TYPE_EDGE);
679680
}
680681

681682
Result RestGraphHandler::edgeActionCreate(graph::Graph& graph,
682-
const std::string& collectionName) {
683+
std::string const& collectionName) {
683684
return edgeCreate(graph, collectionName);
684685
}
685686

686687
Result RestGraphHandler::vertexModify(graph::Graph& graph,
687-
const std::string& collectionName,
688-
const std::string& key, bool isPatch) {
688+
std::string const& collectionName,
689+
std::string const& key, bool isPatch) {
689690
return documentModify(graph, collectionName, key, isPatch,
690691
TRI_COL_TYPE_DOCUMENT);
691692
}
692693

693694
Result RestGraphHandler::vertexCreate(graph::Graph& graph,
694-
const std::string& collectionName) {
695+
std::string const& collectionName) {
695696
return documentCreate(graph, collectionName, TRI_COL_TYPE_DOCUMENT);
696697
}
697698

698699
// /_api/gharial/{graph-name}/edge/{definition-name}
699700
Result RestGraphHandler::editEdgeDefinition(
700-
graph::Graph& graph, const std::string& edgeDefinitionName) {
701+
graph::Graph& graph, std::string const& edgeDefinitionName) {
701702
return modifyEdgeDefinition(graph, EdgeDefinitionAction::EDIT,
702703
edgeDefinitionName);
703704
}
@@ -819,7 +820,7 @@ Result RestGraphHandler::modifyVertexDefinition(
819820
return Result();
820821
}
821822
Result RestGraphHandler::removeEdgeDefinition(
822-
graph::Graph& graph, const std::string& edgeDefinitionName) {
823+
graph::Graph& graph, std::string const& edgeDefinitionName) {
823824
return modifyEdgeDefinition(graph, EdgeDefinitionAction::REMOVE,
5CE
824825
edgeDefinitionName);
825826
}
@@ -831,8 +832,8 @@ Result RestGraphHandler::removeEdgeDefinition(
831832
// TODO the document API also supports mergeObjects, silent and ignoreRevs;
832833
// should gharial, too?
833834
Result RestGraphHandler::documentModify(graph::Graph& graph,
834-
const std::string& collectionName,
835-
const std::string& key, bool isPatch,
835+
std::string const& collectionName,
836+
std::string const& key, bool isPatch,
836837
TRI_col_type_e colType) {
837838
bool parseSuccess = false;
838839
VPackSlice body = this->parseVPackBody(parseSuccess);
@@ -950,8 +951,8 @@ Result RestGraphHandler::documentCreate(graph::Graph& graph,
950951
}
951952

952953
Result RestGraphHandler::vertexActionRemove(graph::Graph& graph,
953-
const std::string& collectionName,
954-
const std::string& key) {
954+
std::string const& collectionName,
955+
std::string const& key) {
955956
bool waitForSync =
956957
_request->parsedValue(StaticStrings::WaitForSyncString, false);
957958

arangod/RestHandler/RestGraphHandler.h

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -76,69 +76,69 @@ class RestGraphHandler : public arangodb::RestVocbaseBaseHandler {
7676

7777
// /_api/gharial/{graph-name}/vertex/{collection-name}
7878
arangodb::Result vertexSetAction(graph::Graph& graph,
79-
const std::string& vertexCollectionName);
79+
std::string const& vertexCollectionName);
8080

8181
// /_api/gharial/{graph-name}/edge/{definition-name}
8282
arangodb::Result edgeSetAction(graph::Graph& graph,
83-
const std::string& edgeDefinitionName);
83+
std::string const& edgeDefinitionName);
8484

8585
// /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
8686
arangodb::Result vertexAction(graph::Graph& graph,
87-
const std::string& vertexCollectionName,
88-
const std::string& vertexKey);
87+
std::string const& vertexCollectionName,
88+
std::string const& vertexKey);
8989

9090
// /_api/gharial/{graph-name}/edge/{definition-name}/{edge-key}
9191
arangodb::Result edgeAction(graph::Graph& graph,
92-
const std::string& edgeDefinitionName,
93-
const std::string& edgeKey);
92+
std::string const& edgeDefinitionName,
93+
std::string const& edgeKey);
9494

9595
// GET /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
96-
void vertexActionRead(graph::Graph& graph, const std::string& collectionName,
97-
const std::string& key);
96+
void vertexActionRead(graph::Graph& graph, std::string const& collectionName,
97+
std::string const& key);
9898

9999
// DELETE /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
100100
arangodb::Result vertexActionRemove(graph::Graph& graph,
101-
const std::string& collectionName,
102-
const std::string& key);
101+
std::string const& collectionName,
102+
std::string const& key);
103103

104104
// PATCH /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
105105
arangodb::Result vertexActionUpdate(graph::Graph& graph,
106-
const std::string& collectionName,
107-
const std::string& key);
106+
std::string const& collectionName,
107+
std::string const& key);
108108

109109
// PUT /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
110110
arangodb::Result vertexActionReplace(graph::Graph& graph,
111-
const std::string& collectionName,
112-
const std::string& key);
111+
std::string const& collectionName,
112+
std::string const& key);
113113

114114
// POST /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
115115
arangodb::Result vertexActionCreate(graph::Graph& graph,
116-
const std::string& collectionName);
116+
std::string const& collectionName);
117117

118118
// GET /_api/gharial/{graph-name}/edge/{definition-name}/{edge-key}
119-
void edgeActionRead(graph::Graph& graph, const std::string& definitionName,
120-
const std::string& key);
119+
void edgeActionRead(graph::Graph& graph, std::string const& definitionName,
120+
std::string const& key);
121121

122122
// DELETE /_api/gharial/{graph-name}/edge/{definition-name}/{edge-key}
123123
arangodb::Result edgeActionRemove(graph::Graph& graph,
124-
const std::string& definitionName,
125-
const std::string& key);
124+
std::string const& definitionName,
125+
std::string const& key);
126126

127127
// POST /_api/gharial/{graph-name}/edge/{definition-name}/{edge-key}
128128
arangodb::Result edgeActionCreate(graph::Graph& graph,
129-
const std::string& definitionName);
129+
std::string const& definitionName);
130130

131131
// PATCH /_api/gharial/{graph-name}/edge/{definition-name}/{edge-key}
132132
arangodb::Result edgeActionUpdate(graph::Graph& graph,
133-
const std::string& collectionName,
134-
const std::string& key);
133+
std::string const& collectionName,
134+
std::string const& key);
135135

136136
// PUT /_api/gharial/{graph-name}/edge/{definition-name}/{edge-key}
137137
arangodb::Result edgeActionReplace(graph::Graph& graph,
138-
const std::string& collectionName,
139-
const std::string& key);
138+
std::string const& collectionName,
139+
std::string const& key);
140140

141-
std::unique_ptr<graph::Graph> getGraph(const std::string& graphName);
141+
std::unique_ptr<graph::Graph> getGraph(std::string const& graphName);
142142

143143
void generateVertexRead(VPackSlice vertex, VPackOptions const& options);
144144

@@ -167,10 +167,10 @@ class RestGraphHandler : public arangodb::RestVocbaseBaseHandler {
167167

168168
void addEtagHeader(velocypack::Slice slice);
169169

170-
Result vertexModify(graph::Graph& graph, const std::string& collectionName,
171-
const std::string& key, bool isPatch);
170+
Result vertexModify(graph::Graph& graph, std::string const& collectionName,
171+
std::string const& key, bool isPatch);
172172

173-
Result vertexCreate(graph::Graph& graph, const std::string& collectionName);
173+
Result vertexCreate(graph::Graph& graph, std::string const& collectionName);
174174

175175
void generateVertexModified(bool wasSynchronous, VPackSlice resultSlice,
176176
const velocypack::Options& options);
@@ -186,16 +186,16 @@ class RestGraphHandler : public arangodb::RestVocbaseBaseHandler {
186186
VPackSlice resultSlice,
187187
const velocypack::Options& options);
188188

189-
Result edgeModify(graph::Graph& graph, const std::string& collectionName,
190-
const std::string& key, bool isPatch);
189+
Result edgeModify(graph::Graph& graph, std::string const& collectionName,
190+
std::string const& key, bool isPatch);
191191

192-
Result edgeCreate(graph::Graph& graph, const std::string& collectionName);
192+
Result edgeCreate(graph::Graph& graph, std::string const& collectionName);
193193

194-
Result documentModify(graph::Graph& graph, const std::string& collectionName,
195-
const std::string& key, bool isPatch,
194+
Result documentModify(graph::Graph& graph, std::string const& collectionName,
195+
std::string const& key, bool isPatch,
196196
TRI_col_type_e colType);
197197

198-
Result documentCreate(graph::Graph& graph, const std::string& collectionName,
198+
Result documentCreate(graph::Graph& graph, std::string const& collectionName,
199199
TRI_col_type_e colType);
200200

201201
Result graphActionReadGraphConfig(graph::Graph const& graph);
@@ -217,11 +217,11 @@ class RestGraphHandler : public arangodb::RestVocbaseBaseHandler {
217217
// edges
218218
// PATCH /_api/gharial/{graph-name}/edge/{definition-name}
219219
Result editEdgeDefinition(graph::Graph& graph,
220-
const std::string& edgeDefinitionName);
220+
std::string const& edgeDefinitionName);
221221

222222
// DELETE /_api/gharial/{graph-name}/edge/{definition-name}
223223
Result removeEdgeDefinition(graph::Graph& graph,
224-
const std::string& edgeDefinitionName);
224+
std::string const& edgeDefinitionName);
225225

226226
// POST /_api/gharial/{graph-name}/edge/
227227
Result createEdgeDefinition(graph::Graph& graph);

arangod/RocksDBEngine/Methods/RocksDBTrxBaseMethods.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ RocksDBTrxBaseMethods::RocksDBTrxBaseMethods(
4747
_readOptions.fill_cache = _state->options().fillBlockCache;
4848
}
4949

50-
RocksDBTrxBaseMethods::~RocksDBTrxBaseMethods() { cleanupTransaction(); }
50+
RocksDBTrxBaseMethods::~RocksDBTrxBaseMethods() {
51+
// cppcheck-suppress *
52+
RocksDBTrxBaseMethods::cleanupTransaction();
53+
}
5154

5255
bool RocksDBTrxBaseMethods::DisableIndexing() {
5356
if (!_indexingDisabled) {

arangod/RocksDBEngine/RocksDBMetaCollection.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,7 @@ void RocksDBMetaCollection::applyUpdates(
15331533
}
15341534

15351535
TRI_IF_FAILURE("applyUpdates::forceHibernation2") {
1536-
if (_revisionTree != nullptr) {
1537-
_revisionTree->hibernate(/*force*/ true);
1538-
}
1536+
_revisionTree->hibernate(/*force*/ true);
15391537
}
15401538
}
15411539

arangod/RocksDBEngine/RocksDBRecoveryManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
324324
// document key
325325
std::string_view ref = RocksDBKey::primaryKey(key);
326326
TRI_ASSERT(!ref.empty());
327+
if (ref.empty()) {
328+
return;
329+
}
327330
// check if the key is numeric
328331
if (ref[0] >= '1' && ref[0] <= '9') {
329332
// numeric start byte. looks good

arangod/RocksDBEngine/RocksDBVPackIndex.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,6 @@ RocksDBVPackIndex::RocksDBVPackIndex(IndexId iid, LogicalCollection& collection,
11831183
.server()
11841184
.getFeature<EngineSelectorFeature>()
11851185
.engine<RocksDBEngine>()),
1186-
_cacheEnabled(basics::VelocyPackHelper::getBooleanValue(
1187-
info, StaticStrings::CacheEnabled, false)),
11881186
_forceCacheRefill(collection.vocbase()
11891187
.server()
11901188
.getFeature<RocksDBIndexCacheRefillFeature>()

arangod/RocksDBEngine/RocksDBVPackIndex.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,6 @@ class RocksDBVPackIndex : public RocksDBIndex {
284284
/// otherwise the non-negative number is the index of the expanding one.
285285
std::vector<int> _expanding;
286286

287-
/// @brief whether or not the user requested to use a cache for the index.
288-
/// note: even if this is set to true, it may not mean that the cache is
289-
/// effectively in use. for example, for system collections and on the
290-
/// coordinator, no cache will actually be used although this flag may be true
291-
bool const _cacheEnabled;
292-
293287
// if true, force a refill of the in-memory cache after each
294288
// insert/update/replace operation
295289
bool const _forceCacheRefill;

0 commit comments

Comments
 (0)
0