Skip to content

Commit 2dc3ba3

Browse files
committed
Initialize Types package
1 parent 1d839c3 commit 2dc3ba3

File tree

33 files changed

+772
-474
lines changed

33 files changed

+772
-474
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of
2+
3+
This query implements the CERT-C rule INT34-C:
4+
5+
> Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand
6+
## CERT
7+
8+
** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` **
9+
10+
## Implementation notes
11+
12+
None
13+
14+
## References
15+
16+
* CERT-C: [INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand](https://wiki.sei.cmu.edu/confluence/display/c)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @id c/cert/do-not-shift-an-expression-by-a-negat
3+
* @name INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of
4+
* @description Do not shift an expression by a negative number of bits or by greater than or equal
5+
* to the number of bits that exist in the operand..
6+
* @kind problem
7+
* @precision very-high
8+
* @problem.severity error
9+
* @tags external/cert/id/int34-c
10+
* external/cert/obligation/rule
11+
*/
12+
13+
import cpp
14+
import codingstandards.c.cert
15+
16+
from
17+
where
18+
not isExcluded(x, TypesPackage::doNotShiftAnExpressionByANegatQuery()) and
19+
select
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# INT34-C: Bit shift should not be done by a negative operand or an operand of greater-or-equal precision than that of another
2+
3+
This query implements the CERT-C rule INT34-C:
4+
5+
> Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand
6+
## CERT
7+
8+
** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` **
9+
10+
## Implementation notes
11+
12+
None
13+
14+
## References
15+
16+
* CERT-C: [INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand](https://wiki.sei.cmu.edu/confluence/display/c)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @id c/cert/expr-shiftedby-negative-or-greater-precision-operand
3+
* @name INT34-C: Bit shift should not be done by a negative operand or an operand of greater-or-equal precision than that of another
4+
* @description Shifting an expression by an operand that is negative or of precision greater or
5+
* equal to that or the another causes representational error.
6+
* @kind problem
7+
* @precision very-high
8+
* @problem.severity error
9+
* @tags external/cert/id/int34-c
10+
* external/cert/obligation/rule
11+
*/
12+
13+
import cpp
14+
import codingstandards.c.cert
15+
16+
from
17+
where
18+
not isExcluded(x, TypesPackage::exprShiftedbyNegativeOrGreaterPrecisionOperandQuery()) and
19+
select
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# INT36-C: Do not convert pointers to integers and back
2+
3+
This query implements the CERT-C rule INT36-C:
4+
5+
> Converting a pointer to integer or integer to pointer
6+
7+
8+
## CERT
9+
10+
** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` **
11+
12+
## Implementation notes
13+
14+
None
15+
16+
## References
17+
18+
* CERT-C: [INT36-C: Converting a pointer to integer or integer to pointer](https://wiki.sei.cmu.edu/confluence/display/c)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @id c/cert/converting-a-pointer-to-integer-or-integer-to-pointer
3+
* @name INT36-C: Do not convert pointers to integers and back
4+
* @description Converting between pointers and integers is not portable and might cause invalid
5+
* memory access.
6+
* @kind problem
7+
* @precision very-high
8+
* @problem.severity error
9+
* @tags external/cert/id/int36-c
10+
* external/cert/obligation/rule
11+
*/
12+
13+
import cpp
14+
import codingstandards.c.cert
15+
16+
from
17+
where
18+
not isExcluded(x, TypesPackage::convertingAPointerToIntegerOrIntegerToPointerQuery()) and
19+
select
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No expected results have yet been specified
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/INT34-C/DoNotShiftAnExpressionByANegat.ql
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No expected results have yet been specified
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/INT34-C/ExprShiftedbyNegativeOrGreaterPrecisionOperand.ql

0 commit comments

Comments
 (0)