Skip to content

Commit f9deae5

Browse files
committed
Refine RULE-21-15
1 parent 3185856 commit f9deae5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointersToCompatibleTypes.ql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ from FunctionCall fc
3535
where
3636
not isExcluded(fc,
3737
StandardLibraryFunctionTypesPackage::memcpyMemmoveMemcmpArgNotPointersToCompatibleTypesQuery()) and
38-
exists(MemCmpMoveCpy memfun | fc.getTarget() = memfun |
38+
exists(MemCmpMoveCpy memfun, Type dstType, Type srcType | fc.getTarget() = memfun |
39+
dstType = fc.getArgument(0).getUnspecifiedType() and
40+
srcType = fc.getArgument(1).getUnspecifiedType() and
3941
(
40-
fc.getArgument(0).getUnspecifiedType() instanceof PointerType and
41-
fc.getArgument(1).getUnspecifiedType() instanceof PointerType
42+
dstType instanceof PointerType and
43+
srcType instanceof PointerType
4244
or
43-
fc.getArgument(0).getUnspecifiedType() instanceof ArrayType and
44-
fc.getArgument(1).getUnspecifiedType() instanceof ArrayType
45+
dstType instanceof ArrayType and
46+
srcType instanceof ArrayType
4547
) and
46-
fc.getArgument(0).getUnspecifiedType() = fc.getArgument(1).getUnspecifiedType()
48+
dstType = srcType
4749
)
4850
select fc, fc.getArgument(0).getUnspecifiedType(), fc.getArgument(1).getUnspecifiedType()

0 commit comments

Comments
 (0)