Skip to content

Commit 93a5683

Browse files
committed
rtl8195am - fix wifi_conf.c warnings
Fix the following warnings: [Warning] wifi_conf.c@326,28: suggest parentheses around comparison in operand of '|' [-Wparentheses] [Warning] wifi_conf.c@451,39: format '%x' expects argument of type 'unsigned int *', but argument 3 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@451,43: format '%x' expects argument of type 'unsigned int *', but argument 4 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@451,47: format '%x' expects argument of type 'unsigned int *', but argument 5 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@451,51: format '%x' expects argument of type 'unsigned int *', but argument 6 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@451,55: format '%x' expects argument of type 'unsigned int *', but argument 7 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,39: format '%x' expects argument of type 'unsigned int *', but argument 3 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,43: format '%x' expects argument of type 'unsigned int *', but argument 4 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,47: format '%x' expects argument of type 'unsigned int *', but argument 5 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,51: format '%x' expects argument of type 'unsigned int *', but argument 6 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,55: format '%x' expects argument of type 'unsigned int *', but argument 7 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,59: format '%x' expects argument of type 'unsigned int *', but argument 8 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,63: format '%x' expects argument of type 'unsigned int *', but argument 9 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,35: format '%x' expects argument of type 'unsigned int *', but argument 10 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,35: format '%x' expects argument of type 'unsigned int *', but argument 11 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,35: format '%x' expects argument of type 'unsigned int *', but argument 12 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,35: format '%x' expects argument of type 'unsigned int *', but argument 13 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,35: format '%x' expects argument of type 'unsigned int *', but argument 14 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@460,35: format '%x' expects argument of type 'unsigned int *', but argument 15 has type 'u32 * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@831,16: format '%d' expects argument of type 'int *', but argument 3 has type 'rtw_security_t * {aka long unsigned int *}' [-Wformat=] [Warning] wifi_conf.c@1335,2: suggest parentheses around assignment used as truth value [-Wparentheses] [Warning] wifi_conf.c@1398,13: pointer targets in passing argument 1 of 'rtw_mfree' differ in signedness [-Wpointer-sign] [Warning] wifi_conf.c@1724,7: variable 'ret' set but not used [-Wunused-but-set-variable] [Warning] wifi_conf.c@1770,6: variable 'ret' set but not used [-Wunused-but-set-variable] Signed-off-by: Tony Wu <[email protected]>
1 parent 7ee2d2a commit 93a5683

File tree

1 file changed

+40
-41
lines changed
  • targets/TARGET_Realtek/TARGET_AMEBA/sdk/common/api/wifi

1 file changed

+40
-41
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/sdk/common/api/wifi/wifi_conf.c

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ extern int inic_stop(void);
6666
/******************************************************
6767
* Variables Declarations
6868
******************************************************/
69-
#if DEVICE_EMAC
70-
//extern struct netif *xnetif[];
71-
#else
69+
#if !DEVICE_EMAC
7270
extern struct netif xnetif[NET_IF_NUM];
7371
#endif
7472
/******************************************************
@@ -325,7 +323,7 @@ static void wifi_disconn_hdl( char* buf, int buf_len, int flags, void* userdata)
325323
else if(rtw_join_status == 0)
326324
error_flag = RTW_CONNECT_FAIL;
327325

328-
else if(rtw_join_status ==JOIN_COMPLETE | JOIN_SECURITY_COMPLETE | JOIN_ASSOCIATED | JOIN_AUTHENTICATED | JOIN_LINK_READY)
326+
else if(rtw_join_status == (JOIN_COMPLETE | JOIN_SECURITY_COMPLETE | JOIN_ASSOCIATED | JOIN_AUTHENTICATED | JOIN_LINK_READY))
329327
error_flag = RTW_WRONG_PASSWORD;
330328
}
331329

@@ -450,7 +448,7 @@ int wifi_connect(
450448

451449
u32 p[5] = {0};
452450
u8 i = 0;
453-
sscanf((const char*)password, "%02x%02x%02x%02x%02x", &p[0], &p[1], &p[2], &p[3], &p[4]);
451+
sscanf((const char*)password, "%02lx%02lx%02lx%02lx%02lx", &p[0], &p[1], &p[2], &p[3], &p[4]);
454452
for(i=0; i< 5; i++)
455453
wep_pwd[i] = (u8)p[i];
456454
wep_pwd[5] = '\0';
@@ -459,8 +457,8 @@ int wifi_connect(
459457
} else if (password_len == 26) {
460458
u32 p[13] = {0};
461459
u8 i = 0;
462-
sscanf((const char*)password, "%02x%02x%02x%02x%02x%02x%02x"\
463-
"%02x%02x%02x%02x%02x%02x", &p[0], &p[1], &p[2], &p[3], &p[4],\
460+
sscanf((const char*)password, "%02lx%02lx%02lx%02lx%02lx%02lx%02lx"\
461+
"%02lx%02lx%02lx%02lx%02lx%02lx", &p[0], &p[1], &p[2], &p[3], &p[4],\
464462
&p[5], &p[6], &p[7], &p[8], &p[9], &p[10], &p[11], &p[12]);
465463
for(i=0; i< 13; i++)
466464
wep_pwd[i] = (u8)p[i];
@@ -830,7 +828,7 @@ int wifi_get_ap_info(rtw_bss_info_t * ap_info, rtw_security_t* security)
830828

831829
snprintf(buf, 24, "get_security");
832830
ret = wext_private_command_with_retval(ifname, buf, buf, 24);
833-
sscanf(buf, "%d", security);
831+
sscanf(buf, "%lu", security);
834832

835833
return ret;
836834
}
@@ -977,8 +975,7 @@ int wifi_on(rtw_mode_t mode)
977975
}
978976

979977
#if CONFIG_LWIP_LAYER
980-
#if DEVICE_EMAC
981-
#else
978+
#if !DEVICE_EMAC
982979
netif_set_up(&xnetif[0]);
983980
if(mode == RTW_MODE_STA_AP) {
984981
netif_set_up(&xnetif[1]);
@@ -1005,9 +1002,7 @@ int wifi_off(void)
10051002
}
10061003
#if CONFIG_LWIP_LAYER
10071004
dhcps_deinit();
1008-
#if DEVICE_EMAC
1009-
// TODO:
1010-
#else
1005+
#if !DEVICE_EMAC
10111006
LwIP_DHCP(0, DHCP_STOP);
10121007
netif_set_down(&xnetif[0]);
10131008
netif_set_down(&xnetif[1]);
@@ -1049,9 +1044,7 @@ int wifi_off_fastly(void)
10491044
{
10501045
#if CONFIG_LWIP_LAYER
10511046
dhcps_deinit();
1052-
#if DEVICE_EMAC
1053-
// TODO:
1054-
#else
1047+
#if !DEVICE_EMAC
10551048
LwIP_DHCP(0, DHCP_STOP);
10561049
#endif
10571050
#endif
@@ -1339,7 +1332,8 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
13391332
memcpy(scan_buf.buf+sizeof(int), ssid, ssid_len);
13401333

13411334
//Scan channel
1342-
if(scan_cnt = (wifi_scan(RTW_SCAN_TYPE_ACTIVE, RTW_BSS_TYPE_ANY, &scan_buf)) < 0){
1335+
scan_cnt = wifi_scan(RTW_SCAN_TYPE_ACTIVE, RTW_BSS_TYPE_ANY, &scan_buf);
1336+
if(scan_cnt < 0){
13431337
WIFI_CONF_MSG("\n\rERROR: wifi scan failed");
13441338
ret = RTW_ERROR;
13451339
}else{
@@ -1402,7 +1396,7 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
14021396
results_handler(scan_buf.buf, scan_buf.buf_len, ssid, user_data);
14031397

14041398
if(scan_buf.buf)
1405-
rtw_mfree(scan_buf.buf, scan_buf.buf_len);
1399+
rtw_mfree((u8 *)scan_buf.buf, scan_buf.buf_len);
14061400

14071401
return ret;
14081402
}
@@ -1678,12 +1672,10 @@ int wifi_restart_ap(
16781672
int channel)
16791673
{
16801674
unsigned char idx = 0;
1675+
#if !DEVICE_EMAC
16811676
ip_addr_t ipaddr;
16821677
ip_addr_t netmask;
16831678
ip_addr_t gw;
1684-
#if DEVICE_EMAC
1685-
//struct netif * pnetif = xnetif[0];
1686-
#else
16871679
struct netif * pnetif = &xnetif[0];
16881680
#endif
16891681
#ifdef CONFIG_CONCURRENT_MODE
@@ -1708,8 +1700,7 @@ int wifi_restart_ap(
17081700
else
17091701
#endif
17101702
{
1711-
#if DEVICE_EMAC
1712-
#else
1703+
#if !DEVICE_EMAC
17131704
IP4_ADDR(&ipaddr, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
17141705
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
17151706
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
@@ -1731,18 +1722,23 @@ int wifi_restart_ap(
17311722
#ifdef CONFIG_CONCURRENT_MODE
17321723
// connect to ap if wlan0 was linked with ap
17331724
if(idx > 0 && sta_linked == 0){
1725+
#if CONFIG_DHCP_CLIENT
17341726
int ret;
1727+
#endif
17351728
printf("\r\nAP: ssid=%s", (char*)setting.ssid);
17361729
printf("\r\nAP: security_type=%d", setting.security_type);
17371730
printf("\r\nAP: password=%s", (char*)setting.password);
17381731
printf("\r\nAP: key_idx =%d\n", setting.key_idx);
1739-
ret = wifi_connect((char*)setting.ssid,
1740-
setting.security_type,
1741-
(char*)setting.password,
1742-
strlen((char*)setting.ssid),
1743-
strlen((char*)setting.password),
1744-
setting.key_idx,
1745-
NULL);
1732+
#if CONFIG_DHCP_CLIENT
1733+
ret =
1734+
#endif
1735+
wifi_connect((char*)setting.ssid,
1736+
setting.security_type,
1737+
(char*)setting.password,
1738+
strlen((char*)setting.ssid),
1739+
strlen((char*)setting.password),
1740+
setting.key_idx,
1741+
NULL);
17461742
#if CONFIG_DHCP_CLIENT
17471743
if(ret == RTW_SUCCESS) {
17481744
/* Start DHCPClient */
@@ -1754,10 +1750,7 @@ int wifi_restart_ap(
17541750
#if (INCLUDE_uxTaskGetStackHighWaterMark == 1)
17551751
printf("\r\nWebServer Thread: High Water Mark is %ld\n", uxTaskGetStackHighWaterMark(NULL));
17561752
#endif
1757-
#if DEVICE_EMAC
1758-
// start dhcp server
1759-
//dhcps_init(xnetif[idx]);
1760-
#else
1753+
#if !DEVICE_EMAC
17611754
// start dhcp server
17621755
dhcps_init(&xnetif[idx]);
17631756
#endif
@@ -1780,15 +1773,22 @@ struct wifi_autoreconnect_param {
17801773

17811774
static void wifi_autoreconnect_thread(void *param)
17821775
{
1776+
#if !DEVICE_EMAC && CONFIG_LWIP_LAYER
17831777
int ret = RTW_ERROR;
1778+
#endif
17841779
struct wifi_autoreconnect_param *reconnect_param = (struct wifi_autoreconnect_param *) param;
17851780
WIFI_CONF_MSG("\n\rauto reconnect ...\n");
1786-
ret = wifi_connect(reconnect_param->ssid, reconnect_param->security_type, reconnect_param->password,
1787-
reconnect_param->ssid_len, reconnect_param->password_len, reconnect_param->key_id, NULL);
1788-
#if DEVICE_EMAC
1789-
// call wlan_emac API
1790-
#else
1791-
#if CONFIG_LWIP_LAYER
1781+
#if !DEVICE_EMAC && CONFIG_LWIP_LAYER
1782+
ret =
1783+
#endif
1784+
wifi_connect(reconnect_param->ssid,
1785+
reconnect_param->security_type,
1786+
reconnect_param->password,
1787+
reconnect_param->ssid_len,
1788+
reconnect_param->password_len,
1789+
reconnect_param->key_id,
1790+
NULL);
1791+
#if !DEVICE_EMAC && CONFIG_LWIP_LAYER
17921792
if(ret == RTW_SUCCESS) {
17931793
#if ATCMD_VER == ATVER_2
17941794
if (dhcp_mode_sta == 2){
@@ -1809,7 +1809,6 @@ static void wifi_autoreconnect_thread(void *param)
18091809
#endif
18101810
}
18111811
}
1812-
#endif //#if CONFIG_LWIP_LAYER
18131812
#endif
18141813
rtw_delete_task(&g_wifi_auto_reconnect_task);
18151814
}

0 commit comments

Comments
 (0)