Skip to content

Commit eca1f26

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import codingstandards.c.Pointers
1616

1717
class MemCmpMoveCpy extends Function {
1818
// Couldn't extend BuiltInFunction because it misses `memcmp`
19-
MemCmpMoveCpy() { this.getName().regexpMatch("mem(cmp|cpy|move)") }
19+
MemCmpMoveCpy() {
20+
this.getName().regexpMatch("mem(cmp|cpy|move)") and
21+
this.getADeclaration().getAFile().(HeaderFile).getBaseName() = "string.h"
22+
}
2023
}
2124

22-
query predicate memfunArgTypes(FunctionCall fc, Type dstType, Type srcType) {
25+
predicate memfunArgTypes(FunctionCall fc, Type dstType, Type srcType) {
2326
(
2427
fc.getArgument(0).getUnspecifiedType() instanceof PointerType and
2528
fc.getArgument(1).getUnspecifiedType() instanceof PointerType

0 commit comments

Comments
 (0)