Skip to content

Commit c9a913b

Browse files
authored
Merge branch 'master' into feature/language-refactor
2 parents 3598a6f + f154b66 commit c9a913b

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

.github/workflows/rustfmt.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ jobs:
1616
components: rustfmt
1717
- run: cargo fmt --all -- --check
1818
- run: cargo clippy --all-features
19+
- run: cargo clippy --features defmt
20+
- run: cargo clippy --features control-buffer-256
21+
- run: cargo clippy

src/control_pipe.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ impl<B: UsbBus> ControlPipe<'_, B> {
154154
| ControlState::DataInLast
155155
| ControlState::DataInZlp
156156
| ControlState::StatusOut => {
157-
self.ep_out.read(&mut []).ok();
157+
let _ = self.ep_out.read(&mut []);
158158
self.state = ControlState::Idle;
159159
}
160160
_ => {
161161
// Discard the packet
162-
self.ep_out.read(&mut []).ok();
162+
let _ = self.ep_out.read(&mut []);
163163

164164
// Unexpected OUT packet
165165
self.set_error()
@@ -235,7 +235,7 @@ impl<B: UsbBus> ControlPipe<'_, B> {
235235
_ => return Err(UsbError::InvalidState),
236236
};
237237

238-
self.ep_in.write(&[]).ok();
238+
let _ = self.ep_in.write(&[]);
239239
self.state = ControlState::StatusIn;
240240
Ok(())
241241
}

src/descriptor/lang_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ pub enum LangID {
349349
MN_MONG_MN = 0x0C50,
350350
DZ_BT = 0x0C51,
351351
TMZ_MA = 0x0C5F,
352-
QUZ_PE = 0x0C6b,
352+
QUZ_PE = 0x0C6B,
353353
LOCALE_CUSTOM_UNSPECIFIED = 0x1000,
354354
AR_LY = 0x1001,
355355
ZH_SG = 0x1004,

src/device.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ impl<B: UsbBus> UsbDevice<'_, B> {
321321
0x0000
322322
};
323323

324-
xfer.accept_with(&status.to_le_bytes()).ok();
324+
let _ = xfer.accept_with(&status.to_le_bytes());
325325
}
326326

327327
(Recipient::Interface, Request::GET_STATUS) => {
328328
let status: u16 = 0x0000;
329329

330-
xfer.accept_with(&status.to_le_bytes()).ok();
330+
let _ = xfer.accept_with(&status.to_le_bytes());
331331
}
332332

333333
(Recipient::Endpoint, Request::GET_STATUS) => {
@@ -339,7 +339,7 @@ impl<B: UsbBus> UsbDevice<'_, B> {
339339
0x0000
340340
};
341341

342-
xfer.accept_with(&status.to_le_bytes()).ok();
342+
let _ = xfer.accept_with(&status.to_le_bytes());
343343
}
344344

345345
(Recipient::Device, Request::GET_DESCRIPTOR) => {
@@ -352,13 +352,13 @@ impl<B: UsbBus> UsbDevice<'_, B> {
352352
_ => CONFIGURATION_NONE,
353353
};
354354

355-
xfer.accept_with(&config.to_le_bytes()).ok();
355+
let _ = xfer.accept_with(&config.to_le_bytes());
356356
}
357357

358358
(Recipient::Interface, Request::GET_INTERFACE) => {
359359
// Reject interface numbers bigger than 255
360360
if req.index > core::u8::MAX.into() {
361-
xfer.reject().ok();
361+
let _ = xfer.reject();
362362
return;
363363
}
364364

@@ -367,22 +367,21 @@ impl<B: UsbBus> UsbDevice<'_, B> {
367367
for cls in classes {
368368
if let Some(setting) = cls.get_alt_setting(InterfaceNumber(req.index as u8))
369369
{
370-
xfer.accept_with(&setting.to_le_bytes()).ok();
370+
let _ = xfer.accept_with(&setting.to_le_bytes());
371371
return;
372372
}
373373
}
374374

375375
// If no class returned an alternate setting, return the default value
376-
xfer.accept_with(&DEFAULT_ALTERNATE_SETTING.to_le_bytes())
377-
.ok();
376+
let _ = xfer.accept_with(&DEFAULT_ALTERNATE_SETTING.to_le_bytes());
378377
}
379378

380379
_ => (),
381380
};
382381
}
383382

384383
if self.control.waiting_for_response() {
385-
self.control.reject().ok();
384+
let _ = self.control.reject();
386385
}
387386
}
388387

@@ -411,13 +410,13 @@ impl<B: UsbBus> UsbDevice<'_, B> {
411410
Request::FEATURE_DEVICE_REMOTE_WAKEUP,
412411
) => {
413412
self.remote_wakeup_enabled = false;
414-
xfer.accept().ok();
413+
let _ = xfer.accept();
415414
}
416415

417416
(Recipient::Endpoint, Request::CLEAR_FEATURE, Request::FEATURE_ENDPOINT_HALT) => {
418417
self.bus
419418
.set_stalled(((req.index as u8) & 0x8f).into(), false);
420-
xfer.accept().ok();
419+
let _ = xfer.accept();
421420
}
422421

423422
(
@@ -426,13 +425,13 @@ impl<B: UsbBus> UsbDevice<'_, B> {
426425
Request::FEATURE_DEVICE_REMOTE_WAKEUP,
427426
) => {
428427
self.remote_wakeup_enabled = true;
429-
xfer.accept().ok();
428+
let _ = xfer.accept();
430429
}
431430

432431
(Recipient::Endpoint, Request::SET_FEATURE, Request::FEATURE_ENDPOINT_HALT) => {
433432
self.bus
434433
.set_stalled(((req.index as u8) & 0x8f).into(), true);
435-
xfer.accept().ok();
434+
let _ = xfer.accept();
436435
}
437436

438437
(Recipient::Device, Request::SET_ADDRESS, 1..=127) => {
@@ -442,59 +441,59 @@ impl<B: UsbBus> UsbDevice<'_, B> {
442441
} else {
443442
self.pending_address = req.value as u8;
444443
}
445-
xfer.accept().ok();
444+
let _ = xfer.accept();
446445
}
447446

448447
(Recipient::Device, Request::SET_CONFIGURATION, CONFIGURATION_VALUE_U16) => {
449448
self.device_state = UsbDeviceState::Configured;
450-
xfer.accept().ok();
449+
let _ = xfer.accept();
451450
}
452451

453452
(Recipient::Device, Request::SET_CONFIGURATION, CONFIGURATION_NONE_U16) => {
454453
match self.device_state {
455454
UsbDeviceState::Default => {
456-
xfer.reject().ok();
455+
let _ = xfer.accept();
457456
}
458457
_ => {
459458
self.device_state = UsbDeviceState::Addressed;
460-
xfer.accept().ok();
459+
let _ = xfer.accept();
461460
}
462461
}
463462
}
464463

465464
(Recipient::Interface, Request::SET_INTERFACE, alt_setting) => {
466465
// Reject interface numbers and alt settings bigger than 255
467466
if req.index > core::u8::MAX.into() || alt_setting > core::u8::MAX.into() {
468-
xfer.reject().ok();
467+
let _ = xfer.reject();
469468
return;
470469
}
471470

472471
// Ask class implementations, whether they accept the alternate interface setting.
473472
for cls in classes {
474473
if cls.set_alt_setting(InterfaceNumber(req.index as u8), alt_setting as u8)
475474
{
476-
xfer.accept().ok();
475+
let _ = xfer.accept();
477476
return;
478477
}
479478
}
480479

481480
// Default behaviour, if no class implementation accepted the alternate setting.
482481
if alt_setting == DEFAULT_ALTERNATE_SETTING_U16 {
483-
xfer.accept().ok();
482+
let _ = xfer.accept();
484483
} else {
485-
xfer.reject().ok();
484+
let _ = xfer.reject();
486485
}
487486
}
488487

489488
_ => {
490-
xfer.reject().ok();
489+
let _ = xfer.reject();
491490
return;
492491
}
493492
}
494493
}
495494

496495
if self.control.waiting_for_response() {
497-
self.control.reject().ok();
496+
let _ = self.control.reject();
498497
}
499498
}
500499

@@ -507,12 +506,11 @@ impl<B: UsbBus> UsbDevice<'_, B> {
507506
xfer: ControlIn<B>,
508507
f: impl FnOnce(&mut DescriptorWriter) -> Result<()>,
509508
) {
510-
xfer.accept(|buf| {
509+
let _ = xfer.accept(|buf| {
511510
let mut writer = DescriptorWriter::new(buf);
512511
f(&mut writer)?;
513512
Ok(writer.position())
514-
})
515-
.ok();
513+
});
516514
}
517515

518516
match dtype {
@@ -595,6 +593,7 @@ impl<B: UsbBus> UsbDevice<'_, B> {
595593
2 => lang.product,
596594
3 => lang.serial,
597595
_ => unreachable!(),
596+
598597
}
599598
}
600599
_ => {
@@ -608,13 +607,13 @@ impl<B: UsbBus> UsbDevice<'_, B> {
608607
if let Some(string_descriptor) = string {
609608
accept_writer(xfer, |w| w.string(string_descriptor));
610609
} else {
611-
xfer.reject().ok();
610+
let _ = xfer.reject();
612611
}
613612
}
614613
},
615614

616615
_ => {
617-
xfer.reject().ok();
616+
let _ = xfer.reject();
618617
}
619618
}
620619
}

src/device_builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B> {
169169
heapless::Vec::from_slice(descriptors).map_err(|_| BuilderError::TooManyLanguages)?;
170170

171171
Ok(self)
172+
172173
}
173174

174175
/// Sets the maximum packet size in bytes for the control endpoint 0.

tests/test_class_host/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn run_tests(tests: &[(&str, TestFn)]) {
6767
}
6868

6969
print!("test {} ... ", name);
70-
stdout().flush().ok();
70+
let _ = stdout().flush();
7171

7272
let mut out = String::new();
7373

0 commit comments

Comments
 (0)