diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2017-11-29 19:11:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-29 21:40:43 -0500 |
commit | edbddb83a15b4361d8c3bf00aabee85fd3ef4d80 (patch) | |
tree | eff0436d3923cb327dbec8251657a411e19d0f43 /scripts/bloat-o-meter | |
parent | d5dabd633922ac5ee5bcc67748f7defb8b211469 (diff) |
scripts/bloat-o-meter: don't fail with division by 0
Under some circumstances it's possible to get a divider 0 which crashes
the script.
Traceback (most recent call last):
File "linux/scripts/bloat-o-meter", line 98, in <module>
print_result("Function", "tTdDbBrR", 2)
File "linux/scripts/bloat-o-meter", line 87, in print_result
(otot, ntot, (ntot - otot)*100.0/otot))
ZeroDivisionError: float division by zero
Hide this by checking the divider first.
Link: http://lkml.kernel.org/r/20171123171219.31453-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/bloat-o-meter')
-rwxr-xr-x | scripts/bloat-o-meter | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 6f099f915dcf..94b664817ad9 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter | |||
@@ -83,8 +83,11 @@ def print_result(symboltype, symbolformat, argc): | |||
83 | for d, n in delta: | 83 | for d, n in delta: |
84 | if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)) | 84 | if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)) |
85 | 85 | ||
86 | print("Total: Before=%d, After=%d, chg %+.2f%%" % \ | 86 | if otot: |
87 | (otot, ntot, (ntot - otot)*100.0/otot)) | 87 | percent = (ntot - otot) * 100.0 / otot |
88 | else: | ||
89 | percent = 0 | ||
90 | print("Total: Before=%d, After=%d, chg %+.2f%%" % (otot, ntot, percent)) | ||
88 | 91 | ||
89 | if sys.argv[1] == "-c": | 92 | if sys.argv[1] == "-c": |
90 | print_result("Function", "tT", 3) | 93 | print_result("Function", "tT", 3) |