Skip to content

Commit 33cc3b7

Browse files
committed
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 <[email protected]>
1 parent 93a5683 commit 33cc3b7

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,20 @@ static uint8_t wlan_get_hwaddr_size(emac_interface_t *emac)
5656

5757
static void wlan_get_hwaddr(emac_interface_t *emac, uint8_t *addr)
5858
{
59-
char mac[20];
60-
if(RTW_SUCCESS == wifi_get_mac_address(mac))
61-
{
62-
if (sscanf(mac, "%x:%x:%x:%x:%x:%x", &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6)
63-
printf("Get HW address failed\r\n");
64-
}else{
59+
char mac[20];
60+
int val[6];
61+
int i;
62+
63+
if (RTW_SUCCESS == wifi_get_mac_address(mac)) {
64+
if (sscanf(mac, "%x:%x:%x:%x:%x:%x",
65+
&val[0], &val[1], &val[2], &val[3], &val[4], &val[5]) != 6)
6566
printf("Get HW address failed\r\n");
67+
68+
for (i = 0; i < 6; i++) {
69+
addr[i] = (unsigned char) val[i];
70+
}
71+
} else {
72+
printf("Get HW address failed\r\n");
6673
}
6774
}
6875

@@ -196,11 +203,18 @@ void mbed_default_mac_address(char *mac) {
196203
void mbed_mac_address(char *mac)
197204
{
198205
char hwaddr[20];
199-
if(RTW_SUCCESS == wifi_get_mac_address(hwaddr))
200-
{
201-
if (sscanf(hwaddr, "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) != 6)
206+
int val[6];
207+
int i;
208+
209+
if (RTW_SUCCESS == wifi_get_mac_address(hwaddr)) {
210+
if (sscanf(hwaddr, "%x:%x:%x:%x:%x:%x",
211+
&val[0], &val[1], &val[2], &val[3], &val[4], &val[5]) != 6)
202212
printf("Get HW address failed\r\n");
203-
}else{
213+
214+
for (i = 0; i < 6; i++) {
215+
mac[i] = (unsigned char) val[i];
216+
}
217+
} else {
204218
printf("Get HW address failed\r\n");
205219
mbed_default_mac_address(mac);
206220
}

0 commit comments

Comments
 (0)