Add tool to find directly recursive calls in toxcore.#1138
Conversation
05ea47a to
0bd2c5b
Compare
|
Does it still fail? You removed its use on Travis. |
nurupo
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 1 approvals obtained (waiting on @iphydf)
other/analysis/check-recursion, line 19 at r1 (raw file):
"opt -analyze -print-callgraph " "2>&1".format(inputs=INPUTS, cflags=CFLAGS), shell=True).split("\n")
Make that line
shell=True).decode('utf8').split("\n")That works for both Python 2 and Python 3.
Otherwise it fails in Python 3 with:
c-toxcore$ python3 t.py
[+0000=0000] Generating callgraph
Traceback (most recent call last):
File "t.py", line 71, in <module>
find_recursion()
File "t.py", line 52, in find_recursion
cg = load_callgraph()
File "t.py", line 19, in load_callgraph
shell=True).split("\n")
TypeError: a bytes-like object is required, not 'str'
nurupo
left a comment
There was a problem hiding this comment.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @iphydf)
other/analysis/check-recursion, line 19 at r1 (raw file):
From Python3 Docs:
0bd2c5b to
f07b553
Compare
Codecov Report
@@ Coverage Diff @@
## master #1138 +/- ##
========================================
+ Coverage 82.7% 82.8% +<.1%
========================================
Files 82 82
Lines 14667 14667
========================================
+ Hits 12140 12147 +7
+ Misses 2527 2520 -7
Continue to review full report at Codecov.
|
iphydf
left a comment
There was a problem hiding this comment.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @nurupo)
other/analysis/check-recursion, line 19 at r1 (raw file):
Previously, nurupo wrote…
From Python3 Docs:
Done.
f6c7a3a to
b8c789c
Compare
nurupo
left a comment
There was a problem hiding this comment.
Reviewed 5 of 5 files at r2, 2 of 2 files at r3.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @iphydf)
other/analysis/check_recursion, line 81 at r3 (raw file):
"-Itoxencryptsave", "$CPPFLAGS", )),
Seems like you forgot to remove inputs and cflags as they are not being used anywhere.
dcf18b7 to
a63f552
Compare
iphydf
left a comment
There was a problem hiding this comment.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @nurupo)
other/analysis/check_recursion, line 81 at r3 (raw file):
Previously, nurupo wrote…
Seems like you forgot to remove
inputsandcflagsas they are not being used anywhere.
Done.
abc8a19 to
1bdce17
Compare
nurupo
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r4.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @iphydf)
other/analysis/check_recursion, line 104 at r4 (raw file):
"add_to_closest -> add_to_closest", "add_to_list -> add_to_list", })
Funny how you went out of your way to make the script generic, to remove all of the hardcoded toxcore and clang commands, yet kept this expected in it. I'd expect the expected check to be done in another python file that imports this one just to call find_recursion(expected={...}). Well, fair enough, I assume you wanted to make the scrips as generic as possible, yet didn't want to make this a multi-file ordeal, so you have settled on having this non-generic part which can be easily removed if needed be.
We should avoid recursion, as it makes reasoning about stack growth harder. This tool shows (currently) 4 (non-tail) recursive functions, at least 2 of which are easy to fix.
1bdce17 to
93cc178
Compare
We should avoid recursion, as it makes reasoning about stack growth
harder. This tool shows (currently) 2 (non-tail) recursive functions. We exempt only these. New recursive functions are not allowed.
This change is