avsync: CF2 fix Coverity Errors [1/1]
PD#SWPL-172623
Problem:
fix Coverity Errors
Solution:
fix Coverity Errors
Verify:
Yocto
Signed-off-by: le.han <le.han@amlogic.com>
Change-Id: I7bf2f2dc786e34e4c6b2f59883b55d57b220b577
diff --git a/src/avsync.c b/src/avsync.c
index cf9c8ee..31bb95f 100644
--- a/src/avsync.c
+++ b/src/avsync.c
@@ -127,8 +127,8 @@
/* pcr master, IPTV only */
bool quit_poll;
enum sync_mode active_mode;
- uint32_t disc_thres_min;
- uint32_t disc_thres_max;
+ int disc_thres_min;
+ int disc_thres_max;
/* error detection */
uint32_t last_poptime;
@@ -238,7 +238,7 @@
bool attach)
{
struct av_sync_session *avsync = NULL;
- char dev_name[20];
+ char dev_name[20] = {0};
int retry = 10;
/* debug log level */
@@ -329,6 +329,7 @@
avsync->last_r_syst = -1;
avsync->timeout = -1;
avsync->apts = AV_SYNC_INVALID_PTS;
+ avsync->fd = -1;
if (msync_session_get_disc_thres(session_id,
&avsync->disc_thres_min, &avsync->disc_thres_max)) {
@@ -345,7 +346,7 @@
while (retry) {
/* wait for sysfs to update */
avsync->fd = open(dev_name, O_RDONLY | O_CLOEXEC);
- if (avsync->fd > 0)
+ if (avsync->fd >= 0)
break;
retry--;
@@ -400,7 +401,7 @@
if (avsync->pcr_monitor)
pcr_monitor_destroy(avsync->pcr_monitor);
err3:
- if (avsync->fd)
+ if (avsync->fd >= 0)
close(avsync->fd);
err2:
avsync->quit_poll = true;
@@ -413,6 +414,8 @@
if (avsync->pattern_detector)
destroy_pattern_detector(avsync->pattern_detector);
err:
+ if (avsync->fd >= 0)
+ close(avsync->fd);
free(avsync);
return NULL;
}
@@ -1141,7 +1144,7 @@
int av_sync_change_mode_by_id(int id, enum sync_mode mode)
{
int fd;
- char dev_name[20];
+ char dev_name[20] = {0};
snprintf(dev_name, sizeof(dev_name), "/dev/%s%d", SESSION_DEV, id);
fd = open(dev_name, O_RDONLY | O_CLOEXEC);