File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -115,8 +115,12 @@ macro_rules! decode_tlv {
115
115
_ => { } ,
116
116
}
117
117
// As we read types, make sure we hit every required type:
118
- $( if ( last_seen_type. is_none( ) || last_seen_type. unwrap( ) < $reqtype) && typ. 0 > $reqtype {
119
- Err ( DecodeError :: InvalidValue ) ?
118
+ $( {
119
+ #[ allow( unused_comparisons) ] // Note that $reqtype may be 0 making the second comparison always true
120
+ let invalid_order = ( last_seen_type. is_none( ) || last_seen_type. unwrap( ) < $reqtype) && typ. 0 > $reqtype;
121
+ if invalid_order {
122
+ Err ( DecodeError :: InvalidValue ) ?
123
+ }
120
124
} ) *
121
125
last_seen_type = Some ( typ. 0 ) ;
122
126
@@ -146,8 +150,12 @@ macro_rules! decode_tlv {
146
150
s. eat_remaining( ) ?;
147
151
}
148
152
// Make sure we got to each required type after we've read every TLV:
149
- $( if last_seen_type. is_none( ) || last_seen_type. unwrap( ) < $reqtype {
150
- Err ( DecodeError :: InvalidValue ) ?
153
+ $( {
154
+ #[ allow( unused_comparisons) ] // Note that $reqtype may be 0 making the second comparison always true
155
+ let missing_req_type = last_seen_type. is_none( ) || last_seen_type. unwrap( ) < $reqtype;
156
+ if missing_req_type {
157
+ Err ( DecodeError :: InvalidValue ) ?
158
+ }
151
159
} ) *
152
160
} }
153
161
}
You can’t perform that action at this time.
0 commit comments