Skip to content

Commit

Permalink
Ensure SendHIDReport returns its status
Browse files Browse the repository at this point in the history
- Added return statement in SendHIDReport function in BootKeyboard.cpp to ensure the function returns the status code from HIDD::SendReport.
- This was triggering simulator testing failures under gcc-14 that
  looked like this:

  ❯ ./basic  -t -q
[==========] Running 5 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 5 tests from GeneratedKTest
[ RUN      ] GeneratedKTest.0_KtestSourceFilename
[ INFO     ] test: /Users/jesse/Documents/GitHub/keyboardio/firmware/Kaleidoscope/tests/plugins/WinKeyToggle/basic/test.ktest
[       OK ] GeneratedKTest.0_KtestSourceFilename (0 ms)
[ RUN      ] GeneratedKTest.1_WinKeyEnabledOnStart
zsh: trace trap  ./basic -t -q

or this:

❯ lldb ./basic
(lldb) target create "./basic"
Current executable set to '/Users/jesse/git/keyboardio/firmware/Kaleidoscope/_build/keyboardio_virtual_model01/plugins/WinKeyToggle/basic/bin/basic' (arm64).
(lldb) run -t -q
Process 31891 launched: '/Users/jesse/git/keyboardio/firmware/Kaleidoscope/_build/keyboardio_virtual_model01/plugins/WinKeyToggle/basic/bin/basic' (arm64)
[==========] Running 5 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 5 tests from GeneratedKTest
[ RUN      ] GeneratedKTest.0_KtestSourceFilename
[ INFO     ] test: /Users/jesse/Documents/GitHub/keyboardio/firmware/Kaleidoscope/tests/plugins/WinKeyToggle/basic/test.ktest
[       OK ] GeneratedKTest.0_KtestSourceFilename (0 ms)
[ RUN      ] GeneratedKTest.1_WinKeyEnabledOnStart
Process 31891 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x100025d64)
    frame #0: 0x0000000100025d64 basic`BootKeyboard_::SendHIDReport(this=0x00000001000dc0a0, data=0x000000016fdfde40, len=36) at BootKeyboard.cpp:73:35
   70
   71  	int BootKeyboard_::SendHIDReport(const void *data, int len) {
   72  	  int returnCode = HIDD::SendReport(0, data, len);
-> 73  	  HIDReportObserver::observeReport(HID_REPORTID_KEYBOARD, data, len, returnCode);
   74  	}
   75
   76  	/*
Target 0: (basic) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x100025d64)
  * frame #0: 0x0000000100025d64 basic`BootKeyboard_::SendHIDReport(this=0x00000001000dc0a0, data=0x000000016fdfde40, len=36) at BootKeyboard.cpp:73:35
    frame #1: 0x000000010001ffdc basic`BootKeyboardAPI::sendReportUnchecked(this=0x00000001000dc0a0) at BootKeyboardAPI.hpp:104:33
    frame #2: 0x000000010002011c basic`BootKeyboardAPI::sendReport(this=0x00000001000dc0a0) at BootKeyboardAPI.hpp:160:24
    frame #3: 0x0000000100020460 basic`kaleidoscope::driver::hid::keyboardio::BootKeyboardWrapper::sendReport(this=0x00000001000dc7e1) at Keyboard.h:66:30
    frame #4: 0x0000000100021828 basic`kaleidoscope::driver::hid::base::Keyboard<kaleidoscope::driver::hid::keyboardio::KeyboardProps>::sendReport(this=0x00000001000dc7e1) at Keyboard.h:120:30
    frame #5: 0x0000000100021340 basic`kaleidoscope::Runtime_::sendKeyboardReport(this=0x00000001000dc388, event=0x000000016fdfdf20) at Runtime.cpp:303:39
    frame #6: 0x0000000100020e90 basic`kaleidoscope::Runtime_::handleKeyEvent(this=0x00000001000dc388, event=KeyEvent @ 0x000000016fdfdf20) at Runtime.cpp:194:21
    frame #7: 0x0000000100020bac basic`kaleidoscope::Runtime_::handleKeyswitchEvent(this=0x00000001000dc388, event=KeyEvent @ 0x000000016fdfdf70) at Runtime.cpp:128:17
    frame #8: 0x00000001000259ac basic`kaleidoscope::driver::keyscanner::Base<kaleidoscope::device::keyboardio::Model01KeyScannerProps>::handleKeyswitchEvent(key=(keyCode_ = '\0', flags_ = '\0'), key_addr=(offset_ = '\0'), key_state='\x02') at Base_Impl.h:45:47
    frame #9: 0x000000010002407c basic`kaleidoscope::device::virt::VirtualKeyScanner::actOnMatrixScan(this=0x00000001000dc7e8) at Virtual.cpp:264:27
    frame #10: 0x0000000100020680 basic`kaleidoscope::device::virt::VirtualKeyScanner::scanMatrix(this=0x00000001000dc7e8) at Virtual.h:66:26
    frame #11: 0x000000010002158c basic`kaleidoscope::device::Base<kaleidoscope::device::virt::VirtualProps>::scanMatrix(this=0x00000001000dc7e0) at Base.h:253:28
    frame #12: 0x0000000100020a04 basic`kaleidoscope::Runtime_::loop(this=0x00000001000dc388) at Runtime.cpp:83:22
    frame #13: 0x000000010000fc38 basic`kaleidoscope::testing::SimHarness::RunCycle() + 124
    frame #14: 0x000000010000fc64 basic`kaleidoscope::testing::SimHarness::RunCycles(unsigned long) + 32
    frame #15: 0x000000010000188c basic`kaleidoscope::testing::(anonymous namespace)::GeneratedKTest_1_WinKeyEnabledOnStart_Test::TestBody() + 76
    frame #16: 0x000000010005ef00 basic`void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) + 104
    frame #17: 0x00000001000565d0 basic`void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) + 60
    frame #18: 0x0000000100035b9c basic`testing::Test::Run() + 240
    frame #19: 0x00000001000367fc basic`testing::TestInfo::Run() + 296
    frame #20: 0x0000000100037334 basic`testing::TestSuite::Run() + 248
    frame #21: 0x0000000100045a64 basic`testing::internal::UnitTestImpl::RunAllTests() + 952
    frame #22: 0x000000010005fefc basic`bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) + 104
    frame #23: 0x00000001000579a0 basic`bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) + 60
    frame #24: 0x0000000100043e70 basic`testing::UnitTest::Run() + 176
    frame #25: 0x0000000100001470 basic`RUN_ALL_TESTS() + 16
    frame #26: 0x0000000100001724 basic`executeTestFunction() + 36
    frame #27: 0x0000000100029240 basic`main(argc=3, argv=0x000000016fdfe8c8) at main.cpp:56:26
    frame #28: 0x0000000198b2c274 dyld`start + 2840
(lldb)
  • Loading branch information
obra committed Dec 4, 2024
1 parent d3e1818 commit f72f6d2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions plugins/KeyboardioHID/src/BootKeyboard/BootKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void BootKeyboard_::setReportDescriptor(uint8_t bootkb_only) {
int BootKeyboard_::SendHIDReport(const void *data, int len) {
int returnCode = HIDD::SendReport(0, data, len);
HIDReportObserver::observeReport(HID_REPORTID_KEYBOARD, data, len, returnCode);
return returnCode;
}

/*
Expand Down

0 comments on commit f72f6d2

Please sign in to comment.