]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: drop duplicated tests in generic_array_bisect()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Jan 2024 19:30:18 +0000 (04:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2024 15:26:17 +0000 (00:26 +0900)
When left == right (== 0), generic_array_bisec_step() does not update
left and right. So the following test is exactly the same.

src/libsystemd/sd-journal/journal-file.c

index c9ff6abca657330d95c27b347dd0d1bdc8ff6074..d3ce5fa7ec9863df7f00bfdebca36f1e1b17a55f 100644 (file)
@@ -3047,7 +3047,7 @@ static int generic_array_bisect(
                 left = 0;
                 right = m - 1;
 
-                if (direction == DIRECTION_UP) {
+                if (direction == DIRECTION_UP && left < right) {
                         /* If we're going upwards, the last entry of the previous array may pass the test,
                          * and the first entry of the current array may not pass. In that case, the last
                          * entry of the previous array must be returned. Hence, we need to test the first