Fixed warning

Check if we are at the end of the string properly
This commit is contained in:
Kristian Lauszus 2013-12-11 10:10:12 +01:00
parent dec1a31bc7
commit 712bc3818d

View file

@ -503,9 +503,12 @@ void BTD::HCI_event_task() {
break; break;
case EV_REMOTE_NAME_COMPLETE: case EV_REMOTE_NAME_COMPLETE:
if (!hcibuf[2]) { // check if reading is OK if (!hcibuf[2]) { // Check if reading is OK
for (uint8_t i = 0; i < min(sizeof (remote_name), sizeof (hcibuf) - 9); i++) for (uint8_t i = 0; i < min(sizeof (remote_name), sizeof (hcibuf) - 9); i++) {
remote_name[i] = hcibuf[9 + i]; remote_name[i] = hcibuf[9 + i];
if (remote_name[i] == '\0') // End of string
break;
}
hci_event_flag |= HCI_FLAG_REMOTE_NAME_COMPLETE; hci_event_flag |= HCI_FLAG_REMOTE_NAME_COMPLETE;
} }
break; break;
@ -789,7 +792,7 @@ void BTD::HCI_task() {
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nRemote Name: "), 0x80); Notify(PSTR("\r\nRemote Name: "), 0x80);
for (uint8_t i = 0; i < 30; i++) { for (uint8_t i = 0; i < 30; i++) {
if (remote_name[i] == NULL) if (remote_name[i] == '\0') // End of string
break; break;
Notifyc(remote_name[i], 0x80); Notifyc(remote_name[i], 0x80);
} }