Skip to content

Commit

Permalink
Fix: compiling warning
Browse files Browse the repository at this point in the history
bug: v/51417

1. Fix compiling warning. Use strlcpy instead of strncpy.

Signed-off-by: Haishen Zhang <[email protected]>
  • Loading branch information
hyson710 committed Jan 1, 2025
1 parent c401358 commit d26420a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions subsys/bluetooth/host/br.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ int bt_br_write_local_name(const char *name)
}

name_cp = net_buf_add(buf, sizeof(*name_cp));
strncpy((char *)name_cp->local_name, name,
strlcpy((char *)name_cp->local_name, name,
sizeof(name_cp->local_name));

return bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_LOCAL_NAME, buf, NULL);
Expand Down Expand Up @@ -1398,4 +1398,4 @@ int bt_br_unpair(bt_addr_t *bdaddr)
#endif /* defined(CONFIG_BT_BREDR) */

return 0;
}
}
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/ssp.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static int pin_code_reply(struct bt_conn *conn, const char *pin, uint8_t len)

bt_addr_copy(&cp->bdaddr, &conn->br.dst);
cp->pin_len = len;
strncpy((char *)cp->pin_code, pin, sizeof(cp->pin_code));
strlcpy((char *)cp->pin_code, pin, sizeof(cp->pin_code));

return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_REPLY, buf, NULL);
}
Expand Down

0 comments on commit d26420a

Please sign in to comment.