Skip to content

Commit 967672a

Browse files
committed
decompress.rs: clippy on 3 if's
1 parent 939dcf8 commit 967672a

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

decompress.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ Int32 BZ2_decompress ( DState* s )
261261
if (s->origPtr < 0)
262262
RETURN(BZ_DATA_ERROR);
263263
if (s->origPtr > 10 + 100000*s->blockSize100k)
264+
RETURN(BZ_DATA_ERROR);
265+
264266
/*--- Receive the mapping table ---*/
265267
for (i = 0; i < 16; i++) {
266268
GET_BIT(BZ_X_MAPPING_1, uc);

decompress.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -702,16 +702,13 @@ pub unsafe fn BZ2_decompress(strm: &mut bz_stream, s: &mut DState) -> ReturnCode
702702
GET_UCHAR!(strm, s, uc);
703703

704704
s.origPtr = s.origPtr << 8 | uc as i32;
705-
if s.origPtr < 0 {
705+
if !(0..10 + 100000 * s.blockSize100k).contains(&s.origPtr) {
706706
retVal = ReturnCode::BZ_DATA_ERROR;
707707
break 'save_state_and_return;
708-
} else if s.origPtr > 10 + 100000 * s.blockSize100k {
709-
retVal = ReturnCode::BZ_DATA_ERROR;
710-
break 'save_state_and_return;
711-
} else {
712-
i = 0;
713-
current_block = 454873545234741267;
714708
}
709+
710+
i = 0;
711+
current_block = 454873545234741267;
715712
}
716713

717714
// mutable because they need to be reborrowed
@@ -829,7 +826,7 @@ pub unsafe fn BZ2_decompress(strm: &mut bz_stream, s: &mut DState) -> ReturnCode
829826

830827
GET_BITS!(strm, s, nGroups, 3);
831828

832-
if !!(2..=6).contains(&nGroups) {
829+
if (2..=6).contains(&nGroups) {
833830
current_block = 14590825336193814119;
834831
continue;
835832
}
@@ -1373,7 +1370,7 @@ pub unsafe fn BZ2_decompress(strm: &mut bz_stream, s: &mut DState) -> ReturnCode
13731370
current_block = 7746242308555130918;
13741371
continue;
13751372
}
1376-
if !!(1..=20).contains(&curr) {
1373+
if (1..=20).contains(&curr) {
13771374
current_block = 17216244326479313607;
13781375
continue 'c_10064;
13791376
}

0 commit comments

Comments
 (0)