Skip to content

Commit fe2e822

Browse files
committed
Use the modulo operator instead of bitwise to improve readability
1 parent b798ae0 commit fe2e822

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nrf-hal-common/src/i2s.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl I2S {
270270
B: WriteBuffer<Word = W>,
271271
{
272272
let (ptr, len) = unsafe { buffer.write_buffer() };
273-
if ptr as u32 & 3 != 0 {
273+
if ptr as u32 % 4 != 0 {
274274
return Err(Error::BufferMisaligned);
275275
}
276276
let maxcnt = (len / (core::mem::size_of::<u32>() / core::mem::size_of::<W>())) as u32;
@@ -305,7 +305,7 @@ impl I2S {
305305
{
306306
let (rx_ptr, rx_len) = unsafe { rx_buffer.write_buffer() };
307307
let (tx_ptr, tx_len) = unsafe { tx_buffer.read_buffer() };
308-
if tx_ptr as u32 & 3 != 0 || rx_ptr as u32 & 3 != 0 {
308+
if tx_ptr as u32 % 4 != 0 || rx_ptr as u32 % 4 != 0 {
309309
return Err(Error::BufferMisaligned);
310310
}
311311
let maxcnt = (tx_len / (core::mem::size_of::<u32>() / core::mem::size_of::<W>())) as u32;
@@ -348,7 +348,7 @@ impl I2S {
348348
B: ReadBuffer<Word = W>,
349349
{
350350
let (ptr, len) = unsafe { buffer.read_buffer() };
351-
if ptr as u32 & 3 != 0 {
351+
if ptr as u32 % 4 != 0 {
352352
return Err(Error::BufferMisaligned);
353353
}
354354
let maxcnt = (len / (core::mem::size_of::<u32>() / core::mem::size_of::<W>())) as u32;

0 commit comments

Comments
 (0)