airvzxf / airvzxf/bose-connect-app-linux
get_paired_devices() silently drops the last paired device from --paired-devices
- 主要語言
- C
- 星號
- 48
- 分支
- 3
- 平均合併
- 2 小時 44 分鐘
- 30 天內合併 PR
- 2
描述
`get_paired_devices()` in `src/library/based.c` reads the correct number of MAC addresses off the wire, but reports one fewer device than it actually read, so the last device in the headphones' pairing list never gets displayed (or looked up via `get_device_info()`).
```c
// src/library/based.c:608-615
uint8_t num_devices_byte = 0;
status = (int)read(sock, &num_devices_byte, 1);
...
num_devices_byte /= BT_ADDR_LEN;
*num_devices = (size_t)(num_devices_byte - 1); // <-- bug
```
```c
// src/library/based.c:624
for (size_t i = 0; i < num_devices_byte; ++i) { // reads num_devices_byte addresses (no -1)
status = (int)read(sock, &addresses[i].b, BT_ADDR_LEN);
...
}
```
The read loop correctly consumes `num_devices_byte` addresses from the socket, but `*num_devices` (used by `do_get_paired_devices()` in `main.c` to size the display loop) is `num_devices_byte - 1`. The last address that was read into the `addresses[]` buffer is simply never shown.
**Repro on real hardware** (Bose Noise Cancelling Headphones 700):
Before fix, `--paired-devices` reports 3, but the device actually has 4 paired (MACs/names redacted, structure preserved):
```
Paired devices: 3
Connected: 2
Device: ! | AA:BB:CC:00:01:01 | Device A
Device: * | AA:BB:CC:00:01:02 | Device B
Device: | AA:BB:CC:00:01:03 | Device C
```
After changing line 615 to `*num_devices = (size_t)num_devices_byte;` (no change to the read loop), the same device now correctly shows all 4:
```
Paired devices: 4
Connected: 2
Device: ! | AA:BB:CC:00:01:01 | Device A
Device: * | AA:BB:CC:00:01:02 | Device B
Device: | AA:BB:CC:00:01:03 | Device C
Device: | AA:BB:CC:00:01:04 | Device D
```
Happy to open a PR with the one-line fix if useful.
貢獻指南
評估
這個 Issue 還沒有評估資料。