Skip to content

Commit

Permalink
Bluetooth: Conn: Add const for conn in bt_conn_get_remote_info
Browse files Browse the repository at this point in the history
The connection object is, and should not, be modified by the function.
Making it const makes it possible to do this simple operation
in functions that also won't change the conn object (i.e.
that uses `const`).

Signed-off-by: Emil Gydesen <[email protected]>
  • Loading branch information
Thalley committed Feb 20, 2025
1 parent e8e1555 commit 0e063a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions include/zephyr/bluetooth/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,7 @@ bool bt_conn_is_type(const struct bt_conn *conn, enum bt_conn_type type);
* @return -EBUSY The remote information is not yet available.
* @return -EINVAL @p conn is not a valid @ref BT_CONN_TYPE_LE or @ref BT_CONN_TYPE_BR connection.
*/
int bt_conn_get_remote_info(struct bt_conn *conn,
struct bt_conn_remote_info *remote_info);
int bt_conn_get_remote_info(const struct bt_conn *conn, struct bt_conn_remote_info *remote_info);

/** @brief Get connection transmit power level.
*
Expand Down
3 changes: 1 addition & 2 deletions subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3003,8 +3003,7 @@ bool bt_conn_is_type(const struct bt_conn *conn, enum bt_conn_type type)
return (conn->type & type) != 0;
}

int bt_conn_get_remote_info(struct bt_conn *conn,
struct bt_conn_remote_info *remote_info)
int bt_conn_get_remote_info(const struct bt_conn *conn, struct bt_conn_remote_info *remote_info)
{
if (!bt_conn_is_type(conn, BT_CONN_TYPE_LE | BT_CONN_TYPE_BR)) {
LOG_DBG("Invalid connection type: %u for %p", conn->type, conn);
Expand Down

0 comments on commit 0e063a1

Please sign in to comment.