Skip to content

Cleanup compiler warnings when using HID device or bonds disabled. #1120

Merged
h2zero merged 2 commits into
masterfrom
fix-compile-warnings
Mar 18, 2026
Merged

Cleanup compiler warnings when using HID device or bonds disabled. #1120
h2zero merged 2 commits into
masterfrom
fix-compile-warnings

Conversation

@h2zero
Copy link
Copy Markdown
Owner

@h2zero h2zero commented Mar 18, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed potential out-of-bounds access in bond address retrieval.
  • Improvements

    • Enhanced bond management and security functions with feature-aware behavior; functions return safe defaults when features are disabled.
  • Deprecations

    • Deprecated startServices() in HID device; service initialization now handled by server startup.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

Arr, these changes be securin' yer NimBLE treasure chest! Conditional compilation guards added for bond management and security functions, runtime-safe fallbacks implemented fer disabled features, and a deprecated method be marked fer future removal. Minor safety fix fer array bounds checkin' as well.

Changes

Cohort / File(s) Summary
Bond Management & Security Guards
src/NimBLEDevice.cpp
Feature-guarded bond functions (getNumBonds, getBondedAddress, isBonded) with MYNEWT_VAL conditionals; runtime fallbacks fer injectPassKey() and injectConfirmPasskey(); explicit (void) casts fer unused args; fixed >= bounds check in getBondedAddress() index comparison.
HID Service Lifecycle
src/NimBLEHIDDevice.cpp, src/NimBLEHIDDevice.h
Removed service startup calls from startServices() method and marked the function as deprecated to offload service initialization to server startup; method now serves as no-op.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

⚓ Bonds be guarded by the feature flag, yarrr!
When BLE_STORE won't sail, our functions stand par,
HID services deprecated, legacy be fine,
Bounds checks and fallbacks—security divine!
Arr, safer seas ahead fer all yer code! 🏴‍☠️

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary objective of the changeset: cleaning up compiler warnings by adding feature guards for bonds and HID device functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-compile-warnings
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/NimBLEDevice.cpp`:
- Around line 1280-1291: The injectPassKey function is incorrectly guarded by
MYNEWT_VAL(BLE_SM_LEGACY) which disables BLE_SM_IOACT_INPUT support in Secure
Connections-only builds; remove the `#if/`#else and always build the passkey
injection path: construct a ble_sm_io with action BLE_SM_IOACT_INPUT and
passkey, call ble_sm_inject_io(peerInfo.getConnHandle(), &pkey), log the result
via NIMBLE_LOGD, and return rc == 0; eliminate the dead
(void)peerInfo/(void)passkey branch and the "not supported" error so
injectPassKey, ble_sm_io, ble_sm_inject_io, BLE_SM_IOACT_INPUT and
NimBLEConnInfo are used unconditionally when the security manager is present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fbf001f1-5d82-4340-8016-e8a93f7d32e4

📥 Commits

Reviewing files that changed from the base of the PR and between 3a9fe64 and 53dde47.

📒 Files selected for processing (3)
  • src/NimBLEDevice.cpp
  • src/NimBLEHIDDevice.cpp
  • src/NimBLEHIDDevice.h

Comment thread src/NimBLEDevice.cpp
@h2zero h2zero merged commit 6854785 into master Mar 18, 2026
42 checks passed
@h2zero h2zero deleted the fix-compile-warnings branch March 18, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant