Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] potential divide by zero in support/scripts/size-stats
@ 2017-11-12  2:17 Andrey Yurovsky
  2017-11-27 21:08 ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: Andrey Yurovsky @ 2017-11-12  2:17 UTC (permalink / raw)
  To: buildroot

I see a divide by zero exception in support/scripts/size-stats when I
use the graph-size target, the package of size zero causing this is
skeleton-init-systemd which I worked out by catching the exception. Is
this package erroneously of size zero or should that be OK?

---
 support/scripts/size-stats | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/support/scripts/size-stats b/support/scripts/size-stats
index af45000..3cd6838 100755
--- a/support/scripts/size-stats
+++ b/support/scripts/size-stats
@@ -178,9 +178,12 @@ def gen_files_csv(filesdict, pkgsizes, outputf):
                      "File size in system (%)"])
         for f, (pkgname, filesize) in filesdict.items():
             pkgsize = pkgsizes[pkgname]
-            wr.writerow([f, pkgname, filesize, pkgsize,
-                         "%.1f" % (float(filesize) / pkgsize * 100),
-                         "%.1f" % (float(filesize) / total * 100)])
+            try:
+                wr.writerow([f, pkgname, filesize, pkgsize,
+                        "%.1f" % (float(filesize) / pkgsize * 100),
+                        "%.1f" % (float(filesize) / total * 100)])
+            except ZeroDivisionError:
+                print('WARNING: \"%s\" is size 0!' % pkgname)


 #
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-20 20:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-12  2:17 [Buildroot] potential divide by zero in support/scripts/size-stats Andrey Yurovsky
2017-11-27 21:08 ` Thomas Petazzoni
2017-11-28  3:37   ` [Buildroot] [PATCH] support/scripts/size-stats: avoid divide-by-zero Andrey Yurovsky
2017-11-28 10:09     ` Yann E. MORIN
2017-11-29 20:36     ` Thomas Petazzoni
2017-12-20 20:52     ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox