Skip to content

Commit 07d78e7

Browse files
committed
[sscanf] use rt_sscanf to replace sscanf
1 parent d025072 commit 07d78e7

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

bsp/allwinner/libraries/libos/src/os.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ int32_t esCFG_GetGPIOSecKeyCount(char *GPIOSecName)
201201
{
202202
return hal_spi_gpio_cfg_count(GPIOSecName);
203203
}
204-
else if (sscanf(GPIOSecName, "twi%d", &id) == 1)
204+
else if (rt_sscanf(GPIOSecName, "twi%d", &id) == 1)
205205
{
206206
return 2;
207207
}
@@ -308,11 +308,11 @@ int32_t esCFG_GetGPIOSecData(char *GPIOSecName, void *pGPIOCfg, int32_t GPIONum)
308308
gpio_cfg++;
309309
}
310310
}
311-
else if (sscanf(GPIOSecName, "spi%d", &id) == 1)
311+
else if (rt_sscanf(GPIOSecName, "spi%d", &id) == 1)
312312
{
313313
return hal_spi_gpio_cfg_load(gpio_cfg, GPIONum, id);
314314
}
315-
else if (sscanf(GPIOSecName, "twi%d", &id) == 1)
315+
else if (rt_sscanf(GPIOSecName, "twi%d", &id) == 1)
316316
{
317317
extern int hal_i2c_gpio_cfg_load(user_gpio_set_t *gpio_cfg, int32_t GPIONum, int id);
318318
return hal_i2c_gpio_cfg_load(gpio_cfg, GPIONum, id);

bsp/nuvoton/libraries/m460/rtt_port/drv_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ void devmem(int argc, char *argv[])
167167

168168
if (argc == 3)
169169
{
170-
if (sscanf(argv[2], "0x%x", &value) != 1)
170+
if (rt_sscanf(argv[2], "0x%x", &value) != 1)
171171
goto exit_devmem;
172172
mode = 1; /*Write*/
173173
}
174174

175-
if (sscanf(argv[1], "0x%x", &u32Addr) != 1)
175+
if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1)
176176
goto exit_devmem;
177177
else if (!u32Addr || u32Addr & (4 - 1))
178178
goto exit_devmem;
@@ -203,12 +203,12 @@ void devmem2(int argc, char *argv[])
203203

204204
if (argc == 3)
205205
{
206-
if (sscanf(argv[2], "%u", &value) != 1)
206+
if (rt_sscanf(argv[2], "%u", &value) != 1)
207207
goto exit_devmem;
208208
word_count = value;
209209
}
210210

211-
if (sscanf(argv[1], "0x%x", &u32Addr) != 1)
211+
if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1)
212212
goto exit_devmem;
213213
else if (!u32Addr || u32Addr & (4 - 1))
214214
goto exit_devmem;

bsp/nuvoton/libraries/ma35/rtt_port/drv_disp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static rt_err_t lcd_set_overlay_colkey(int argc, char **argv)
399399

400400
for (index = 0; index < (len - 1); index ++)
401401
{
402-
if (sscanf(argv[index + 1], "%x", &arg[index]) != 1)
402+
if (rt_sscanf(argv[index + 1], "%x", &arg[index]) != 1)
403403
return -1;
404404
}
405405
rt_kprintf("colkeylow:0x%08x colkeyhigh:0x%08x\n", arg[0], arg[1]);
@@ -459,7 +459,7 @@ static rt_err_t lcd_set_alphablend_opmode(int argc, char **argv)
459459

460460
for (index = 0; index < (len - 1); index ++)
461461
{
462-
if (sscanf(argv[index + 1], "%x", &arg[index]) != 1)
462+
if (rt_sscanf(argv[index + 1], "%x", &arg[index]) != 1)
463463
return -1;
464464
}
465465

bsp/nuvoton/libraries/ma35/rtt_port/drv_sys.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,12 @@ void devmem(int argc, char *argv[])
307307

308308
if (argc == 3)
309309
{
310-
if (sscanf(argv[2], "0x%x", &value) != 1)
310+
if (rt_sscanf(argv[2], "0x%x", &value) != 1)
311311
goto exit_devmem;
312312
mode = 1; //Write
313313
}
314314

315-
if (sscanf(argv[1], "0x%x", &u32Addr) != 1)
315+
if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1)
316316
goto exit_devmem;
317317
else if (u32Addr & (4 - 1))
318318
goto exit_devmem;
@@ -343,12 +343,12 @@ void devmem2(int argc, char *argv[])
343343

344344
if (argc == 3)
345345
{
346-
if (sscanf(argv[2], "%d", &value) != 1)
346+
if (rt_sscanf(argv[2], "%d", &value) != 1)
347347
goto exit_devmem;
348348
word_count = value;
349349
}
350350

351-
if (sscanf(argv[1], "0x%x", &u32Addr) != 1)
351+
if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1)
352352
goto exit_devmem;
353353
else if (u32Addr & (4 - 1))
354354
goto exit_devmem;

bsp/nuvoton/libraries/n9h30/rtt_port/drv_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ void devmem(int argc, char *argv[])
9090

9191
if (argc == 3)
9292
{
93-
if (sscanf(argv[2], "0x%x", &value) != 1)
93+
if (rt_sscanf(argv[2], "0x%x", &value) != 1)
9494
goto exit_devmem;
9595
mode = 1; //Write
9696
}
9797

98-
if (sscanf(argv[1], "0x%x", &u32Addr) != 1)
98+
if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1)
9999
goto exit_devmem;
100100
else if (!u32Addr || u32Addr & (4 - 1))
101101
goto exit_devmem;

bsp/nuvoton/libraries/nu_packages/Demo/wormhole_demo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,12 @@ void whc_devmem(int argc, char *argv[])
298298

299299
if (argc == 3)
300300
{
301-
if (sscanf(argv[2], "0x%x", &value) != 1)
301+
if (rt_sscanf(argv[2], "0x%x", &value) != 1)
302302
goto exit_devmem;
303303
mode = 1; //Write
304304
}
305305

306-
if (sscanf(argv[1], "0x%x", &u32Addr) != 1)
306+
if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1)
307307
goto exit_devmem;
308308
else if (u32Addr & (4 - 1))
309309
goto exit_devmem;

components/drivers/phy/ofw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ rt_err_t rt_ofw_get_phyid(struct rt_ofw_node *np,rt_uint32_t *id)
116116
if (ret)
117117
return ret;
118118

119-
ret = sscanf(phy_id,"ethernet-phy-id%4x.%4x",&upper, &lower);
119+
ret = rt_sscanf(phy_id,"ethernet-phy-id%4x.%4x",&upper, &lower);
120120
if(ret != 2)
121121
return -RT_ERROR;
122122

components/net/at/at_socket/at_socket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ static void at_connect_notice_cb(struct at_socket *sock, at_socket_evt_t event,
759759
}
760760
new_sock = at_get_socket(new_socket);
761761
new_sock->state = AT_SOCKET_CONNECT;
762-
sscanf(buff, "SOCKET:%d", &base_socket);
762+
rt_sscanf(buff, "SOCKET:%d", &base_socket);
763763
LOG_D("ACCEPT BASE SOCKET: %d", base_socket);
764764
new_sock->user_data = (void *)base_socket;
765765

@@ -985,7 +985,7 @@ int at_accept(int socket, struct sockaddr *name, socklen_t *namelen)
985985
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
986986
}
987987

988-
sscanf(&receive_buff[0], "SOCKET:%d", &new_socket);
988+
rt_sscanf(&receive_buff[0], "SOCKET:%d", &new_socket);
989989
new_sock = at_get_socket(new_socket);
990990
ip4_addr_set_any(&remote_addr);
991991
ipaddr_port_to_socketaddr(name, &remote_addr, &remote_port);

documentation/at/at.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ int at_req_parse_args(const char *req_args, const char *req_expr, ...);
260260
261261
Among the four functions of an AT command, only the setting function has an input parameter, and the input parameter is to remove the rest of the AT command. For example, for a given command input `"AT+TEST=1,2,3,4"`, set the input parameter of the function to the parameter string `"=1,2,3,4"`.
262262
263-
The command parsing function is mainly used in the AT function setting function, which is used to parse the incoming string parameter and obtain corresponding multiple input parameters for performing the following operations. The standard `sscanf` parsing grammar used in parsing grammar here will also be described in detail later in the AT Client parameter parsing function.
263+
The command parsing function is mainly used in the AT function setting function, which is used to parse the incoming string parameter and obtain corresponding multiple input parameters for performing the following operations. The standard `rt_sscanf` parsing grammar used in parsing grammar here will also be described in detail later in the AT Client parameter parsing function.
264264
265265
| **Parameter** | **Description** |
266266
|---------|-----------------------------------------------|
@@ -537,7 +537,7 @@ The implementation principle of sending and receiving data is relatively simple.
537537
538538
### AT Client Data Parsing Method ###
539539
540-
After the data is normally acquired, the response data needs to be parsed, which is one of the important functions of the AT Client. Parsing of data in the AT Client provides a parsed form of a custom parsing expression whose parsing syntax uses the standard `sscanf` parsing syntax. Developers can use the custom data parsing expression to respond to useful information in the data, provided that the developer needs to review the relevant manual in advance to understand the basic format of the AT Server device response data that the AT Client connects to. The following is a simple AT Client data parsing method through several functions and routines.
540+
After the data is normally acquired, the response data needs to be parsed, which is one of the important functions of the AT Client. Parsing of data in the AT Client provides a parsed form of a custom parsing expression whose parsing syntax uses the standard `rt_sscanf` parsing syntax. Developers can use the custom data parsing expression to respond to useful information in the data, provided that the developer needs to review the relevant manual in advance to understand the basic format of the AT Server device response data that the AT Client connects to. The following is a simple AT Client data parsing method through several functions and routines.
541541
542542
#### Get Response Data for the Specified Line Number
543543
@@ -609,7 +609,7 @@ int at_resp_parse_line_args_by_kw(at_response_t resp, const char *keyword, const
609609
610610
This function is used to get a row of data containing a keyword in the AT Server response data and parse the parameters in the row data.
611611
612-
The data parsing syntax uses the standard `sscanf` syntax, the content of the syntax is more, developers can search their parsing syntax, here two procedures are used to introduce the simple use method.
612+
The data parsing syntax uses the standard `rt_sscanf` syntax, the content of the syntax is more, developers can search their parsing syntax, here two procedures are used to introduce the simple use method.
613613
614614
#### Serial Port Configuration Information Analysis Example
615615
@@ -676,7 +676,7 @@ printf("IP=%s, MAC=%s\n", ip, mac);
676676
at_delete_resp(resp);
677677
```
678678
679-
The key to parsing data is to correctly define the expression. Because the response data of the different device manufacturers is not unique to the response data of the AT device, only the form of the custom parsing expression can be obtained to obtain the required information. The design of the `at_resp_parse_line_args` parsing parameter function is based on the `sscanf` data parsing method. Before using it, the developer needs to understand the basic parsing syntax and then design the appropriate parsing syntax in combination with the response data. If the developer does not need to parse the specific parameters, you can use the `at_resp_get_line` function to get the specific data of a row.
679+
The key to parsing data is to correctly define the expression. Because the response data of the different device manufacturers is not unique to the response data of the AT device, only the form of the custom parsing expression can be obtained to obtain the required information. The design of the `at_resp_parse_line_args` parsing parameter function is based on the `rt_sscanf` data parsing method. Before using it, the developer needs to understand the basic parsing syntax and then design the appropriate parsing syntax in combination with the response data. If the developer does not need to parse the specific parameters, you can use the `at_resp_get_line` function to get the specific data of a row.
680680
681681
### AT Client URC Data Processing ###
682682

examples/test/avl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ int main(int argc, char *argv[])
556556
{
557557
if (argc == 2)
558558
{
559-
sscanf(argv[1], "%d", &loop_count);
559+
rt_sscanf(argv[1], "%d", &loop_count);
560560
}
561561
else
562562
{

0 commit comments

Comments
 (0)