You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
1.2 KiB

From d58e871a424fedf286747816e9525fc2287bb72d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 2 Oct 2018 12:26:23 +0200
Subject: [PATCH] journal-verify: add comment and silence LGTM warning
(cherry picked from commit 0a587335d2a16a48479b10969491a7353d78c25b)
Resolves: #1694605
---
src/journal/journal-verify.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index 250d4c7586..7c6d8ab780 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -70,10 +70,11 @@ static void draw_progress(uint64_t p, usec_t *last_usec) {
}
static uint64_t scale_progress(uint64_t scale, uint64_t p, uint64_t m) {
+ /* Calculates scale * p / m, but handles m == 0 safely, and saturates.
+ * Currently all callers use m >= 1, but we keep the check to be defensive.
+ */
- /* Calculates scale * p / m, but handles m == 0 safely, and saturates */
-
- if (p >= m || m == 0)
+ if (p >= m || m == 0) // lgtm[cpp/constant-comparison]
return scale;
return scale * p / m;