File tree Expand file tree Collapse file tree
cpp/ql/test/query-tests/JPL_C/LOC-3/Rule 13/LimitedScopeFile Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ | file1.c:3:5:3:14 | globalInt1 | The global variable globalInt1 is not accessed outside of file1.c and could be made static. |
2+ | file1.c:5:5:5:14 | globalInt3 | The global variable globalInt3 is not accessed outside of file1.c and could be made static. |
Original file line number Diff line number Diff line change 1+ JPL_C/LOC-3/Rule 13/LimitedScopeFile.ql
Original file line number Diff line number Diff line change 1+ // file1.c
2+
3+ int globalInt1 ; // BAD [only accessed in this file]
4+ int globalInt2 ; // GOOD [accessed in file1.c and file2.c]
5+ int globalInt3 ; // GOOD [referenced in file1.h] [FALSE POSITIVE]
6+ int globalInt4 ; // GOOD [only accessed in one function, should be function scope instead]
7+ int globalInt5 ; // GOOD [not accessed]
8+
9+ static int staticInt1 ; // GOOD [static]
10+
11+ void file1Func1 ()
12+ {
13+ globalInt1 ++ ;
14+ globalInt2 ++ ;
15+ globalInt3 ++ ;
16+ globalInt4 ++ ;
17+ staticInt1 ++ ;
18+ }
19+
20+ void file1Func2 ()
21+ {
22+ globalInt1 ++ ;
23+ globalInt3 ++ ;
24+ staticInt1 ++ ;
25+ }
Original file line number Diff line number Diff line change 1+ // file2.c
2+
3+ #include "file1.h"
4+
5+ extern int globalInt2 ;
6+
7+ void file2Func ()
8+ {
9+ globalInt2 ++ ;
10+ }
You can’t perform that action at this time.
0 commit comments