From 02bda05e5b2dcea76faa9c46dbfa7747a6b3a4ba Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Wed, 8 May 2013 14:21:28 -0500 Subject: [PATCH] handle division by zero with no swap Reported by Stefan Praszalowicz --- smem | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smem b/smem index 2d9a9c0..0cbd925 100755 --- a/smem +++ b/smem @@ -222,6 +222,8 @@ def showamount(a, total): if options.abbreviate: return units(a * 1024) elif options.percent: + if total == 0: + return 'N/A' return "%.2f%%" % (100.0 * a / total) return a