aboutsummaryrefslogtreecommitdiffstats
path: root/debian/patches/0016-fix-div-by-zero-zfscompressedarcmeter.patch
blob: a548469e4caaff8a45fe96beb088d4df237a457a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
From 099dab88be5a7a1c9207e7bc7116618b7108f851 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Thu, 22 Apr 2021 17:12:02 +0200
Subject: [PATCH] ZfsCompressedArcMeter: avoid division by 0

On systems not using ZFS `this->values[0]` is zero.
---
 zfs/ZfsCompressedArcMeter.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/zfs/ZfsCompressedArcMeter.c
+++ b/zfs/ZfsCompressedArcMeter.c
@@ -33,7 +33,11 @@
 }
 
 static void ZfsCompressedArcMeter_printRatioString(const Meter* this, char* buffer, size_t size) {
-   xSnprintf(buffer, size, "%.2f:1", this->total / this->values[0]);
+   if (this->values[0] > 0) {
+      xSnprintf(buffer, size, "%.2f:1", this->total / this->values[0]);
+   } else {
+      xSnprintf(buffer, size, "N/A");
+   }
 }
 
 static void ZfsCompressedArcMeter_updateValues(Meter* this, char* buffer, size_t size) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy