]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
f_flower: Remove always zero checks
authorMaks Mishin <maks.mishinfz@gmail.com>
Sun, 7 Jul 2024 17:27:41 +0000 (20:27 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 17 Jul 2024 23:47:57 +0000 (16:47 -0700)
Expression 'ttl & ~(255 >> 0)' is always zero, because right operand
has 8 trailing zero bits, which is greater or equal than the size
of the left operand == 8 bits.

Found by RASU JSC.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/f_flower.c

index 08c1001af7b4e5fb1d25c5e93291e9daa156e036..244f0f7e6141101ea4e1dff73917e7c44d8b0b03 100644 (file)
@@ -1523,7 +1523,7 @@ static int flower_parse_mpls_lse(int *argc_p, char ***argv_p,
 
                        NEXT_ARG();
                        ret = get_u8(&ttl, *argv, 10);
-                       if (ret < 0 || ttl & ~(MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)) {
+                       if (ret < 0) {
                                fprintf(stderr, "Illegal \"ttl\"\n");
                                return -1;
                        }
@@ -1936,7 +1936,7 @@ static int flower_parse_opt(const struct filter_util *qu, char *handle,
                        }
                        mpls_format_old = true;
                        ret = get_u8(&ttl, *argv, 10);
-                       if (ret < 0 || ttl & ~(MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)) {
+                       if (ret < 0) {
                                fprintf(stderr, "Illegal \"mpls_ttl\"\n");
                                return -1;
                        }