Skip to content

Commit

Permalink
Fix hipGraphGetEdges behavior wrt numEdges
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Dec 8, 2023
1 parent 16dd5fa commit 40d5847
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/CHIPBindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,26 @@ hipError_t hipGraphGetEdges(hipGraph_t graph, hipGraphNode_t *from,
hipGraphNode_t *to, size_t *numEdges) {
CHIP_TRY
CHIPInitialize();
NULLCHECK(numEdges);
auto Edges = GRAPH(graph)->getEdges();
if (!to && !from) {
*numEdges = Edges.size();
RETURN(hipSuccess);
}

for (int i = 0; i < Edges.size(); i++) {
int to_return = *numEdges < Edges.size() ? *numEdges : Edges.size();

Check warning on line 361 in src/CHIPBindings.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/CHIPBindings.cc:361:7 [readability-identifier-naming]

invalid case style for local variable 'to_return'
for (int i = 0; i < to_return; i++) {

Check warning on line 362 in src/CHIPBindings.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/CHIPBindings.cc:362:12 [readability-identifier-naming]

invalid case style for local variable 'i'
auto Edge = Edges[i];
auto FromNode = Edge.first;
auto ToNode = Edge.second;
from[i] = HIPGRAPHNODE(FromNode);
to[i] = HIPGRAPHNODE(ToNode);
}
for (int i = to_return; i < *numEdges; i++) {

Check warning on line 369 in src/CHIPBindings.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/CHIPBindings.cc:369:12 [readability-identifier-naming]

invalid case style for local variable 'i'
from[i] = nullptr;
to[i] = nullptr;
}
*numEdges = to_return;
RETURN(hipSuccess);
CHIP_CATCH
}
Expand Down

0 comments on commit 40d5847

Please sign in to comment.