Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clippy nightly has a new warning for us: error: this loop never actually loops --> x11rb-protocol/src/packet_reader.rs:135:9 | 135 | / for mut packet in packets { 136 | | let original_packet = packet.clone(); 137 | | 138 | | loop { ... | 148 | | } 149 | | } | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop = note: `#[deny(clippy::never_loop)]` on by default help: if you need the first element of the iterator, try writing | 135 | if let Some(mut packet) = packets.into_iter().next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It turns out that the function test_packets(), which is supposed to test that a list of packets is correctly read by PacketReader, only ever tested the first packet and ignored everything else. This commit fixes the test. First, test_packets() now puts all the packet data into one, big chunk, instead of feeding the packets already on the right boundaries to the PacketReader. After all, we want to test that this correctly determines the boundaries again. After fixing that, the test started to fail. It turns out that two of the tests actually produced packages whose length is not a multiple of four, but all X11 packets must have a length that is a multiple of four. Fix this by rounding down to a correct multiple. These tests were added in commit 2082b2b. Before that, there were no tests at all. Signed-off-by: Uli Schlachter <[email protected]>
- Loading branch information