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