From: Zbigniew Jędrzejewski-Szmek Date: Tue, 2 Oct 2018 10:26:23 +0000 (+0200) Subject: journal-verify: add comment and silence LGTM warning X-Git-Tag: v240~648^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a587335d2a16a48479b10969491a7353d78c25b;p=thirdparty%2Fsystemd.git journal-verify: add comment and silence LGTM warning --- diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index c2f0467c6e3..5569ddc3136 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -60,10 +60,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;