From 05237843bd4f93d5ea386ace11220c70eca7f47c Mon Sep 17 00:00:00 2001 From: Amit Purwar Date: Thu, 26 Dec 2019 12:28:12 +0530 Subject: [PATCH] Resolves the build error for strncpy Change-Id: I3ccd06ce99ce14cfa6a583c73bde66b533054085 Signed-off-by: Amit Purwar --- bt-oal/common/oal-utils.c | 12 +++++++----- bt-oal/common/oal-utils.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bt-oal/common/oal-utils.c b/bt-oal/common/oal-utils.c index 65a7e8e..76861f1 100755 --- a/bt-oal/common/oal-utils.c +++ b/bt-oal/common/oal-utils.c @@ -24,6 +24,7 @@ #include #include #include "oal-utils.h" +#include "oal-manager.h" char *bdt_bd2str(const bt_address_t *bdaddr, bdstr_t *bdstr) { @@ -40,15 +41,16 @@ char *bdt_bd2str(const bt_address_t *bdaddr, bdstr_t *bdstr) return *bdstr; } -char* convert_bdaddr_2_str(const bt_bdaddr_t *bd_addr, char *buf) +char* convert_bdaddr_2_str(const bt_bdaddr_t *bd_addr, char *buf, int len) { const uint8_t *p; if (!bd_addr) - return strncpy(buf, "NULL", sizeof("NULL")); + return strncpy(buf, "NULL", len); + p = bd_addr->address; - snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x", + snprintf(buf, len, "%02x:%02x:%02x:%02x:%02x:%02x", p[0], p[1], p[2], p[3], p[4], p[5]); return buf; @@ -56,8 +58,8 @@ char* convert_bdaddr_2_str(const bt_bdaddr_t *bd_addr, char *buf) char *bdaddr_2_str(const bt_bdaddr_t *bd_addr) { - static char buf[18]; - return convert_bdaddr_2_str(bd_addr, buf); + static char buf[BT_ADDRESS_STR_LEN]; + return convert_bdaddr_2_str(bd_addr, buf, BT_ADDRESS_STR_LEN); } void string_to_uuid(char *str, service_uuid_t *p_uuid) diff --git a/bt-oal/common/oal-utils.h b/bt-oal/common/oal-utils.h index 7c3a782..1e8295f 100755 --- a/bt-oal/common/oal-utils.h +++ b/bt-oal/common/oal-utils.h @@ -438,7 +438,7 @@ char* convert_bt_property_2_str(const bt_property_t *property); char* convert_property_type_2_str(bt_property_type_t prop_type); char* convert_scan_mode_2_str(bt_scan_mode_t scan_mode); char* convert_device_type_2_str(bt_device_type_t device_type); -char* convert_bdaddr_2_str(const bt_bdaddr_t *bd_addr, char *buf); +char* convert_bdaddr_2_str(const bt_bdaddr_t *bd_addr, char *buf, int len); void local_le_feat_2_string(char *str, const bt_local_le_features_t *f); const char *dump_uuid_name(int uuid_no); -- 2.7.4