mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-05 13:42:07 +00:00
IOC Mediator: Replace strtok with strsep
Replace strtok function with strsep function. Tracked-On: #1401 Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Reviewed-by: Shuo Liu <shuo.a.liu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
69edccc063
commit
25db6b7917
@ -1548,27 +1548,37 @@ vm_resume_handler(void *arg)
|
|||||||
int
|
int
|
||||||
ioc_parse(const char *opts)
|
ioc_parse(const char *opts)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp, *str, *cpy;
|
||||||
char *param = strdup(opts);
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
tmp = strtok(param, ",");
|
cpy = str = strdup(opts);
|
||||||
rc = snprintf(virtual_uart_path, sizeof(virtual_uart_path), "%s", param);
|
if (!cpy)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IOC mediator parameters format as below:
|
||||||
|
* <virtual_uart_path>[,<wakeup_reason>]
|
||||||
|
* For e.g. "/run/acrn/ioc_vm1,0x20"
|
||||||
|
*/
|
||||||
|
tmp = strsep(&str, ",");
|
||||||
|
if (!tmp)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
rc = snprintf(virtual_uart_path, sizeof(virtual_uart_path), "%s", tmp);
|
||||||
if (rc < 0 || rc >= sizeof(virtual_uart_path))
|
if (rc < 0 || rc >= sizeof(virtual_uart_path))
|
||||||
WPRINTF("ioc gets incomplete virtual uart path:%s\r\n",
|
WPRINTF("ioc gets incomplete virtual uart path:%s\r\n",
|
||||||
virtual_uart_path);
|
virtual_uart_path);
|
||||||
if (tmp != NULL) {
|
|
||||||
tmp = strtok(NULL, ",");
|
|
||||||
if (tmp != NULL) {
|
|
||||||
ioc_boot_reason = strtoul(tmp, 0, 0);
|
|
||||||
|
|
||||||
/*
|
if (!str)
|
||||||
* Mask invalid bits of wakeup reason for IOC mediator
|
goto exit;
|
||||||
*/
|
|
||||||
ioc_boot_reason &= CBC_WK_RSN_ALL;
|
ioc_boot_reason = strtoul(str, 0, 0);
|
||||||
}
|
|
||||||
}
|
/* Mask invalid bits of wakeup reason for IOC mediator */
|
||||||
free(param);
|
ioc_boot_reason &= CBC_WK_RSN_ALL;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
free(cpy);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user