Skip to content

Commit fef6ab6

Browse files
committed
qdl: Satisfy clippy
Clippy doesn't like hand-rolled "is_multiple_of()" or nested if statements, address this to silence the paperclip. Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
1 parent 3382ea0 commit fef6ab6

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

qdl/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn firehose_write<T: QdlChan>(channel: &mut T, buf: &mut [u8]) -> anyhow::Re
161161
let mut b = buf.to_vec();
162162

163163
// XML can't be n * 512 bytes long by fh spec
164-
if !buf.is_empty() && buf.len() % 512 == 0 {
164+
if !buf.is_empty() && buf.len().is_multiple_of(512) {
165165
println!("{}", "INFO: Appending '\n' to outgoing XML".bright_black());
166166
b.push(b'\n');
167167
}
@@ -223,9 +223,9 @@ pub fn firehose_configure<T: QdlChan>(
223223
) -> anyhow::Result<()> {
224224
let config = channel.fh_config();
225225
// Spec requirement
226-
assert!(config.send_buffer_size % config.storage_sector_size == 0);
226+
assert!(config.send_buffer_size.is_multiple_of(config.storage_sector_size));
227227
// Sanity requirement
228-
assert!(config.send_buffer_size % config.storage_sector_size == 0);
228+
assert!(config.send_buffer_size.is_multiple_of(config.storage_sector_size));
229229
let mut xml = firehose_xml_setup(
230230
"configure",
231231
&[

qdl/src/sahara.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn sahara_dump_region<T: QdlChan>(
421421
bytes_read += channel.read(&mut buf)?;
422422

423423
// Issue a dummy read to consume the ZLP
424-
if channel.fh_config().backend == QdlBackend::Usb && buf.len() % 512 == 0 {
424+
if channel.fh_config().backend == QdlBackend::Usb && buf.len().is_multiple_of(512) {
425425
let _ = channel.read(&mut []);
426426
}
427427

@@ -536,14 +536,12 @@ pub fn sahara_run<T: QdlChan>(
536536
}
537537
}
538538
SaharaCmd::SaharaDoneResp => {
539-
if let SaharaPacketBody::DoneResp(req) = pkt.body {
540-
if req.status == 1 /* COMPLETE */
541-
/* 8916 bug */
542-
|| images.len() == 1
543-
{
544-
println!("{}", "Loader sent. Hack away!".green());
545-
return Ok(vec![]);
546-
}
539+
if let SaharaPacketBody::DoneResp(req) = pkt.body
540+
&& (req.status == 1 /* COMPLETE */ /* 8916 bug */ ||
541+
images.len() == 1)
542+
{
543+
println!("{}", "Loader sent. Hack away!".green());
544+
return Ok(vec![]);
547545
}
548546
}
549547
SaharaCmd::SaharaCommandReady => {

0 commit comments

Comments
 (0)