diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2016-10-04 10:21:42 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2016-10-04 12:44:24 +0000 |
commit | a8de2de1f235ba31e15540400372928f6f2c4437 (patch) | |
tree | 29152f6c3ccdf4b6042978bce9f4d0d990fbcbaa /net | |
parent | 76947d7fe6e9f1725daee0c7309089d6f43cdc2d (diff) |
Bluetooth: Fix compiler warnings/errors related to string casts
Fix the following compiler warnings/errors that show up with llvm:
tests/bluetooth/shell/src/main.c:594:2: error:
initializing 'const uint8_t *' (aka 'const unsigned char *') with an
expression of type 'char [11]' converts between pointers to integer types
with different sign [-Werror,-Wpointer-sign]
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/bluetooth/bluetooth.h:93:11: note: expanded
from macro 'BT_DATA'
.data = (_data), \
^~~~~~~
1 error generated.
net/bluetooth/hci_core.c:1759:22: error: passing
'uint8_t [248]' to parameter of type 'const char *' converts between
pointers to integer types with different sign [-Werror,-Wpointer-sign]
name_len = strlen(evt->name);
^~~~~~~~~
lib/libc/minimal/include/string.h:32:34: note: passing
argument to parameter 's' here
extern size_t strlen(const char *s);
^
CC net/bluetooth/log.o
net/bluetooth/hci_core.c:3136:10: error: passing
'uint8_t [248]' to parameter of type 'char *' converts between pointers to
integer types with different sign [-Werror,-Wpointer-sign]
strncpy(name_cp->local_name, CONFIG_BLUETOOTH_BREDR_NAME,
^~~~~~~~~~~~~~~~~~~
lib/libc/minimal/include/string.h:30:39: note: passing
argument to parameter 'd' here
extern char *strncpy(char *_Restrict d, const char *_Restrict s, size_t n);
net/bluetooth/conn.c:301:10: error: passing
'uint8_t [16]' to parameter of type 'char *' converts between pointers to
integer types with different sign [-Werror,-Wpointer-sign]
strncpy(cp->pin_code, pin, sizeof(cp->pin_code));
^~~~~~~~~~~~
lib/libc/minimal/include/string.h:30:39: note: passing
argument to parameter 'd' here
extern char *strncpy(char *_Restrict d, const char *_Restrict s, size_t n);
Change-Id: I342131c6c2b25445382b2317d673561c4087096b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/conn.c | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/net/bluetooth/conn.c b/net/bluetooth/conn.c index 04599eebc..8ba19f971 100644 --- a/net/bluetooth/conn.c +++ b/net/bluetooth/conn.c @@ -298,7 +298,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(cp->pin_code, pin, sizeof(cp->pin_code)); + strncpy((char *)cp->pin_code, pin, sizeof(cp->pin_code)); return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_REPLY, buf, NULL); } diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e45a8ebfb..4b294b96c 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1756,7 +1756,7 @@ static void remote_name_request_complete(struct net_buf *buf) eir_len -= 2; /* name is null terminated */ - name_len = strlen(evt->name); + name_len = strlen((const char *)evt->name); if (name_len > eir_len) { eir[0] = eir_len + 1; @@ -3133,7 +3133,7 @@ static int br_init(void) } name_cp = net_buf_add(buf, sizeof(*name_cp)); - strncpy(name_cp->local_name, CONFIG_BLUETOOTH_BREDR_NAME, + strncpy((char *)name_cp->local_name, CONFIG_BLUETOOTH_BREDR_NAME, sizeof(name_cp->local_name)); err = bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_LOCAL_NAME, buf, NULL); |