From 0149de55c47e67219cd66bf9d18b9ee3ff076c0a Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Mon, 28 Oct 2013 07:40:24 +1300 Subject: [PATCH] Add a guard when calculating the disk percentage used. --- ChangeLog | 3 +++ bin/mythtv-status | 9 ++++++++- debian/changelog | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c0e912..6e99f72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2013-10-28 Andrew Ruthven + Guard against zero total disk space, this affected Werner Mahr. + 2013-10-27 Andrew Ruthven Handle the handling in POD in Perl 5.18. Force the return code =item lines to be handled correctly. diff --git a/bin/mythtv-status b/bin/mythtv-status index 4291646..151b0f3 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -1063,8 +1063,15 @@ sub calc_disk_space_percentage { return 'unknown'; } + # Guard against zero disk space. + $total = normalise_disk_space($total); + if ($total == 0) { + warn "Total disk space is 0 MB, I can't use that to calculate a percentage!\n"; + return 'unknown'; + } + my $percent = sprintf("%.1f", - normalise_disk_space($used) / normalise_disk_space($total) * 100); + normalise_disk_space($used) / $total * 100); if ($percent >= $c->{'disk_space_warn'}) { $exit_value ||= 1; diff --git a/debian/changelog b/debian/changelog index 08fbe47..4ac5457 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ mythtv-status (0.10.4) unstable; urgency=low - * New upstream release (Closes: #724166, #709377). + * New upstream release (Closes: #724166, #709377, #709449). * Remove an extraneous hypen in our postinst (Cloases: #704436) Thank you Francois Marier for the patch. - -- Andrew Ruthven Sun, 27 Oct 2013 23:23:08 +1300 + -- Andrew Ruthven Mon, 28 Oct 2013 07:39:55 +1300 mythtv-status (0.10.3) unstable; urgency=low -- 2.30.2