audio: replace banned function
Replace banned function
Change-Id: I65fca98b26cd99005b5e7a76ec59b9cc5335ea43
diff --git a/hal/audio_extn/maxxaudio.c b/hal/audio_extn/maxxaudio.c
index 31feb02..a8f09fc 100644
--- a/hal/audio_extn/maxxaudio.c
+++ b/hal/audio_extn/maxxaudio.c
@@ -352,7 +352,7 @@
static bool find_sup_dev(char *name)
{
- char *token;
+ char *token, *saveptr = NULL;
const char s[2] = ",";
bool ret = false;
char sup_devs[128];
@@ -362,7 +362,7 @@
// 2. Both string content are equal
strncpy(sup_devs, SUPPORT_DEV, sizeof(sup_devs));
- token = strtok(sup_devs, s);
+ token = strtok_r(sup_devs, s, &saveptr);
while (token != NULL) {
if (strncmp(token, name, strlen(token)) == 0 &&
strlen(token) == strlen(name)) {
@@ -370,7 +370,7 @@
ret = true;
break;
}
- token = strtok(NULL, s);
+ token = strtok_r(NULL, s, &saveptr);
}
return ret;
@@ -399,6 +399,7 @@
int ret = 0;
int32_t fd = -1;
char *idd;
+ char *saveptr = NULL;
if (enable) {
ret = snprintf(path, sizeof(path), "/proc/asound/card%u/usbid", card);
@@ -418,7 +419,7 @@
goto done;
}
//replace '\n' to '\0'
- idd = strtok(id, "\n");
+ idd = strtok_r(id, "\n", &saveptr);
if (find_sup_dev(idd)) {
ALOGV("%s: support usbid is %s", __func__, id);
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index e6859fe..c952fae 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -628,6 +628,7 @@
int32_t fd=-1;
char path[128];
int ret = 0;
+ char *saveptr = NULL;
memset(usb_card_info->usbid, 0, sizeof(usb_card_info->usbid));
@@ -655,7 +656,7 @@
goto done;
}
- strtok(usb_card_info->usbid, "\n");
+ strtok_r(usb_card_info->usbid, "\n", &saveptr);
done:
if (fd >= 0)