Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
75eef2c1
Commit
75eef2c1
authored
Apr 20, 2017
by
4ast
Committed by
GitHub
Apr 20, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #656 from iovisor/non-static-functions
Disable non-static function calls
parents
cee60569
3f28e7bc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
3 deletions
+22
-3
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.cc
+9
-0
tests/python/test_clang.py
tests/python/test_clang.py
+11
-1
tools/pidpersec.py
tools/pidpersec.py
+1
-1
tools/vfsstat.py
tools/vfsstat.py
+1
-1
No files found.
src/cc/frontends/clang/b_frontend_action.cc
View file @
75eef2c1
...
...
@@ -462,6 +462,15 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
rewriter_
.
ReplaceText
(
expansionRange
(
Call
->
getSourceRange
()),
text
);
}
}
}
else
if
(
FunctionDecl
*
F
=
dyn_cast
<
FunctionDecl
>
(
Decl
))
{
if
(
F
->
isExternallyVisible
()
&&
!
F
->
getBuiltinID
())
{
auto
start_loc
=
rewriter_
.
getSourceMgr
().
getFileLoc
(
Decl
->
getLocStart
());
if
(
rewriter_
.
getSourceMgr
().
getFileID
(
start_loc
)
==
rewriter_
.
getSourceMgr
().
getMainFileID
())
{
error
(
Call
->
getLocStart
(),
"cannot call non-static helper function"
);
return
false
;
}
}
}
}
return
true
;
...
...
tests/python/test_clang.py
View file @
75eef2c1
...
...
@@ -522,7 +522,17 @@ int do_next(struct pt_regs *ctx) {
with
self
.
assertRaises
(
KeyError
):
b1
[
"dummy"
][
c_key
]
def
test_invalid_noninline_call
(
self
):
text
=
"""
int bar(void) {
return 0;
}
int foo(struct pt_regs *ctx) {
return bar();
}
"""
with
self
.
assertRaises
(
Exception
):
b
=
BPF
(
text
=
text
)
if
__name__
==
"__main__"
:
...
...
tools/pidpersec.py
View file @
75eef2c1
...
...
@@ -28,7 +28,7 @@ enum stat_types {
BPF_ARRAY(stats, u64, S_MAXSTAT + 1);
void stats_increment(int key) {
static
void stats_increment(int key) {
u64 *leaf = stats.lookup(&key);
if (leaf) (*leaf)++;
}
...
...
tools/vfsstat.py
View file @
75eef2c1
...
...
@@ -51,7 +51,7 @@ enum stat_types {
BPF_ARRAY(stats, u64, S_MAXSTAT + 1);
void stats_increment(int key) {
static
void stats_increment(int key) {
u64 *leaf = stats.lookup(&key);
if (leaf) (*leaf)++;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment