From 33cc3b7907f9f7ec9b702247f8e26f573d446728 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 17 Apr 2018 16:18:01 +0800 Subject: [PATCH] rtl8195am - fix rtw_emac.cpp warnings Fix the following warnings: [Warning] rtw_emac.cpp@62,104: format '%x' expects argument of type 'unsigned int*', but argument 3 has type 'uint8_t* {aka unsigned char*}' [-Wformat=] [Warning] rtw_emac.cpp@62,104: format '%x' expects argument of type 'unsigned int*', but argument 4 has type 'uint8_t* {aka unsigned char*}' [-Wformat=] [Warning] rtw_emac.cpp@62,104: format '%x' expects argument of type 'unsigned int*', but argument 5 has type 'uint8_t* {aka unsigned char*}' [-Wformat=] [Warning] rtw_emac.cpp@62,104: format '%x' expects argument of type 'unsigned int*', but argument 6 has type 'uint8_t* {aka unsigned char*}' [-Wformat=] [Warning] rtw_emac.cpp@62,104: format '%x' expects argument of type 'unsigned int*', but argument 7 has type 'uint8_t* {aka unsigned char*}' [-Wformat=] [Warning] rtw_emac.cpp@62,104: format '%x' expects argument of type 'unsigned int*', but argument 8 has type 'uint8_t* {aka unsigned char*}' [-Wformat=] [Warning] rtw_emac.cpp@201,101: format '%x' expects argument of type 'unsigned int*', but argument 3 has type 'char*' [-Wformat=] [Warning] rtw_emac.cpp@201,101: format '%x' expects argument of type 'unsigned int*', but argument 4 has type 'char*' [-Wformat=] [Warning] rtw_emac.cpp@201,101: format '%x' expects argument of type 'unsigned int*', but argument 5 has type 'char*' [-Wformat=] [Warning] rtw_emac.cpp@201,101: format '%x' expects argument of type 'unsigned int*', but argument 6 has type 'char*' [-Wformat=] [Warning] rtw_emac.cpp@201,101: format '%x' expects argument of type 'unsigned int*', but argument 7 has type 'char*' [-Wformat=] [Warning] rtw_emac.cpp@201,101: format '%x' expects argument of type 'unsigned int*', but argument 8 has type 'char*' [-Wformat=] Signed-off-by: Tony Wu --- .../TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp b/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp index 9f9a3fff43..7374c3c983 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp +++ b/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp @@ -56,13 +56,20 @@ static uint8_t wlan_get_hwaddr_size(emac_interface_t *emac) static void wlan_get_hwaddr(emac_interface_t *emac, uint8_t *addr) { - char mac[20]; - if(RTW_SUCCESS == wifi_get_mac_address(mac)) - { - if (sscanf(mac, "%x:%x:%x:%x:%x:%x", &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6) - printf("Get HW address failed\r\n"); - }else{ + char mac[20]; + int val[6]; + int i; + + if (RTW_SUCCESS == wifi_get_mac_address(mac)) { + if (sscanf(mac, "%x:%x:%x:%x:%x:%x", + &val[0], &val[1], &val[2], &val[3], &val[4], &val[5]) != 6) printf("Get HW address failed\r\n"); + + for (i = 0; i < 6; i++) { + addr[i] = (unsigned char) val[i]; + } + } else { + printf("Get HW address failed\r\n"); } } @@ -196,11 +203,18 @@ void mbed_default_mac_address(char *mac) { void mbed_mac_address(char *mac) { char hwaddr[20]; - if(RTW_SUCCESS == wifi_get_mac_address(hwaddr)) - { - if (sscanf(hwaddr, "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) != 6) + int val[6]; + int i; + + if (RTW_SUCCESS == wifi_get_mac_address(hwaddr)) { + if (sscanf(hwaddr, "%x:%x:%x:%x:%x:%x", + &val[0], &val[1], &val[2], &val[3], &val[4], &val[5]) != 6) printf("Get HW address failed\r\n"); - }else{ + + for (i = 0; i < 6; i++) { + mac[i] = (unsigned char) val[i]; + } + } else { printf("Get HW address failed\r\n"); mbed_default_mac_address(mac); }