]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Avoid redundant conditions
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 15 May 2025 13:11:45 +0000 (13:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 May 2025 20:46:47 +0000 (13:46 -0700)
While `if (i <= 0) ... else if (i > 0) ...` is technically equivalent to
`if (i <= 0) ... else ...`, the latter is vastly easier to read because
it avoids writing out a condition that is unnecessary. Let's drop such
unnecessary conditions.

Pointed out by CodeQL.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
help.c
transport-helper.c

diff --git a/help.c b/help.c
index 6ef90838f128af23ac9b976093fd498357bb9284..21b778707a6a653b909d86e613b6d1109555ce1a 100644 (file)
--- a/help.c
+++ b/help.c
@@ -214,7 +214,7 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
                else if (cmp == 0) {
                        ei++;
                        free(cmds->names[ci++]);
-               } else if (cmp > 0)
+               } else
                        ei++;
        }
 
index 69391ee7d28e110f199f64cc86c8583a9815bd39..0789e5bca53282d29f30eea9a2eca129e115f40f 100644 (file)
@@ -1437,7 +1437,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
                transfer_debug("%s EOF (with %i bytes in buffer)",
                        t->src_name, (int)t->bufuse);
                t->state = SSTATE_FLUSHING;
-       } else if (bytes > 0) {
+       } else {
                t->bufuse += bytes;
                transfer_debug("Read %i bytes from %s (buffer now at %i)",
                        (int)bytes, t->src_name, (int)t->bufuse);