Skip to content

Commit 0d963e6

Browse files
authored
[SYCL][Graph] Fix coverity warnings in graph code (#12999)
- Fix `COPY_WITHOUT_ASSIGN` warning in `node_impl` by adding copy-assignment operator. - Fix (false positive?) `REVERSE_INULL` in `graph_impl.hpp` by adding braces to make it explicit what is being dereferenced.
1 parent bca61db commit 0d963e6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sycl/source/detail/graph_impl.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ class node_impl {
154154
MCGType(Other.MCGType), MNodeType(Other.MNodeType),
155155
MCommandGroup(Other.getCGCopy()), MSubGraphImpl(Other.MSubGraphImpl) {}
156156

157+
/// Copy-assignment operator. This will perform a deep-copy of the
158+
/// command group object associated with this node.
159+
node_impl &operator=(node_impl &Other) {
160+
if (this != &Other) {
161+
MSuccessors = Other.MSuccessors;
162+
MPredecessors = Other.MPredecessors;
163+
MCGType = Other.MCGType;
164+
MNodeType = Other.MNodeType;
165+
MCommandGroup = Other.getCGCopy();
166+
MSubGraphImpl = Other.MSubGraphImpl;
167+
}
168+
return *this;
169+
}
170+
157171
/// Checks if this node has a given requirement.
158172
/// @param Requirement Requirement to lookup.
159173
/// @return True if \p Requirement is present in node, false otherwise.
@@ -669,7 +683,7 @@ class graph_impl {
669683
void addEventForNode(std::shared_ptr<graph_impl> GraphImpl,
670684
std::shared_ptr<sycl::detail::event_impl> EventImpl,
671685
std::shared_ptr<node_impl> NodeImpl) {
672-
if (!EventImpl->getCommandGraph())
686+
if (!(EventImpl->getCommandGraph()))
673687
EventImpl->setCommandGraph(GraphImpl);
674688
MEventsMap[EventImpl] = NodeImpl;
675689
}

0 commit comments

Comments
 (0)