Commit edbddb83 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

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: default avatarAndy Shevchenko <>
Cc: Alexey Dobriyan <>
Cc: Vaneet Narang <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent d5dabd63
......@@ -83,8 +83,11 @@ def print_result(symboltype, symbolformat, argc):
for d, n in delta:
if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d))
print("Total: Before=%d, After=%d, chg %+.2f%%" % \
(otot, ntot, (ntot - otot)*100.0/otot))
if otot:
percent = (ntot - otot) * 100.0 / otot
percent = 0
print("Total: Before=%d, After=%d, chg %+.2f%%" % (otot, ntot, percent))
if sys.argv[1] == "-c":
print_result("Function", "tT", 3)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment