xen/misra: xen-analysis.py: fix return error on PhaseExceptions
PATCH 1/1 xen/misra: xen-analysis.py: fix return error on PhaseExceptions
Currently the script return code is 0 even if an exception is found, because the return code is written only if the exception object has the errorcode member.
Fix the issue returning the errorcode member in case it exists, otherwise use a generic value different from 0.
--- xen/scripts/xen-analysis.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
xen/scripts/xen-analysis.py +1 -2
@@ -26,8 +26,7 @@ def main(argv): cppcheck_analysis.generate_cppcheck_report() except PhaseExceptions as e: print("ERROR: {}".format(e)) - if hasattr(e, "errorcode"): - ret_code = e.errorcode + ret_code = e.errorcode if hasattr(e, "errorcode") else 1 finally: if settings.step_clean_analysis: cppcheck_analysis.clean_analysis_artifacts()
Signature · 1 line
2.34.1
Quoted 18 lines · Luca Fancellu
Currently the script return code is 0 even if an exception is found, because the return code is written only if the exception object has the errorcode member.
Fix the issue returning the errorcode member in case it exists, otherwise use a generic value different from 0.
Fixes 02b26c02c7c4 ("xen/scripts: add cppcheck tool to the xen-analysis.py script")Signed-off-by Luca Fancellu <[email protected]>--- xen/scripts/xen-analysis.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)xen/scripts/xen-analysis.py +0
-0
xen/scripts/xen-analysis.py def main(argv): · line 29
Quoted 6 lines
xen/scripts/xen-analysis.py +1
-2@@ -26,8 +26,7 @@ def main(argv): cppcheck_analysis.generate_cppcheck_report() except PhaseExceptions as e: print("ERROR: {}".format(e)) - if hasattr(e, "errorcode"): - ret_code = e.errorcode + ret_code = e.errorcode if hasattr(e, "errorcode") else 1
ret_code = getattr(e, "errorcode", 1)
is rather more succinct, and pythonic.
~Andrew
Quoted 32 lines · Andrew Cooper
Quoted 18 lines · Luca Fancellu
Currently the script return code is 0 even if an exception is found, because the return code is written only if the exception object has the errorcode member.
Fix the issue returning the errorcode member in case it exists, otherwise use a generic value different from 0.
Fixes 02b26c02c7c4 ("xen/scripts: add cppcheck tool to the xen-analysis.py script")Signed-off-by Luca Fancellu <[email protected]>---
xen/scripts/xen-analysis.py| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)xen/scripts/xen-analysis.py +0
-0xen/scripts/xen-analysis.py def main(argv): · line 29
Quoted 6 lines
xen/scripts/xen-analysis.py +1
-2@@ -26,8 +26,7 @@ def main(argv): cppcheck_analysis.generate_cppcheck_report() except PhaseExceptions as e: print("ERROR: {}".format(e)) - if hasattr(e, "errorcode"): - ret_code = e.errorcode + ret_code = e.errorcode if hasattr(e, "errorcode") else 1
ret_code=getattr(e, "errorcode", 1)
Quoted 1 line
is rather more succinct, and pythonic.
Yes it looks better, I’ll update the patch
Quoted 2 lines
~Andrew