hal: Fix incorrect wsa count update during platform_init
buf is not reset after each read_line_from_file call.
Hence buf is matching with wsa after first wsa thermal
zone is found. This results in wsa_count being more than 2.
Buffer is reset after each iteration to fix this issue.
Change-Id: I73b1bd350c0a8659e7a42b5ccdb7600935254ae6
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 21b6bce..b0c24ac 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -2005,7 +2005,6 @@
}
while ((tdirent = readdir(tdir))) {
- char buf[50];
struct dirent *tzdirent;
DIR *tzdir = NULL;
@@ -2013,6 +2012,7 @@
if (!tzdir)
continue;
while ((tzdirent = readdir(tzdir))) {
+ char buf[50] = {0};
if (strcmp(tzdirent->d_name, "type"))
continue;
snprintf(name, MAX_PATH, TZ_TYPE, tzn);
@@ -2020,11 +2020,11 @@
read_line_from_file(name, buf, sizeof(buf));
if (strstr(buf, file)) {
wsa_count++;
- /*We support max only two WSA speakers*/
- if (wsa_count == 2)
- break;
}
tzn++;
+ /*We support max only two WSA speakers*/
+ if (wsa_count == 2)
+ break;
}
closedir(tzdir);
}