Skip to content

Commit 3cab634

Browse files
committed
These comparisons are always false
0 > u64 is redundant because a u64 can't be less than zero
1 parent 594c101 commit 3cab634

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lightning/src/util/ser_macros.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ macro_rules! encode_tlv_stream {
5454
let mut last_seen: Option<u64> = None;
5555
$(
5656
if let Some(t) = last_seen {
57-
#[allow(unused_comparisons)] // Note that $type may be 0 making the following comparison always true
57+
#[allow(unused_comparisons)] // Note that $type may be 0 making the following comparison always false
5858
(debug_assert!($type > t))
5959
}
6060
last_seen = Some($type);
@@ -106,14 +106,14 @@ macro_rules! encode_varint_length_prefixed_tlv {
106106
#[macro_export]
107107
macro_rules! check_tlv_order {
108108
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, (default_value, $default: expr)) => {{
109-
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
109+
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always false
110110
let invalid_order = ($last_seen_type.is_none() || $last_seen_type.unwrap() < $type) && $typ.0 > $type;
111111
if invalid_order {
112112
$field = $default;
113113
}
114114
}};
115115
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, required) => {{
116-
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
116+
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always false
117117
let invalid_order = ($last_seen_type.is_none() || $last_seen_type.unwrap() < $type) && $typ.0 > $type;
118118
if invalid_order {
119119
return Err(DecodeError::InvalidValue);
@@ -134,14 +134,14 @@ macro_rules! check_tlv_order {
134134
#[macro_export]
135135
macro_rules! check_missing_tlv {
136136
($last_seen_type: expr, $type: expr, $field: ident, (default_value, $default: expr)) => {{
137-
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
137+
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always false
138138
let missing_req_type = $last_seen_type.is_none() || $last_seen_type.unwrap() < $type;
139139
if missing_req_type {
140140
$field = $default;
141141
}
142142
}};
143143
($last_seen_type: expr, $type: expr, $field: ident, required) => {{
144-
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
144+
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always false
145145
let missing_req_type = $last_seen_type.is_none() || $last_seen_type.unwrap() < $type;
146146
if missing_req_type {
147147
return Err(DecodeError::InvalidValue);

0 commit comments

Comments
 (0)