avsync-lib: CF1 deal with coverty errors [1/1]
PD#TV-61224
Problem:
coverty errors
Solution:
mod related coverty errors
Verify:
AR321
Change-Id: I65930757e06abac483c5d94d3aafd6b3376171cb
Signed-off-by: hanghang.luo <hanghang.luo@amlogic.com>
diff --git a/src/avsync.c b/src/avsync.c
index 389c432..a195c5c 100644
--- a/src/avsync.c
+++ b/src/avsync.c
@@ -303,7 +303,7 @@
if (msync_session_get_disc_thres(session_id,
&avsync->disc_thres_min, &avsync->disc_thres_max)) {
- log_error("fail to get disc thres", dev_name, errno);
+ log_error("dev_name:%s; errno:%d; fail to get disc thres", dev_name, errno);
avsync->disc_thres_min = AV_DISC_THRES_MIN;
avsync->disc_thres_max = AV_DISC_THRES_MAX;
}
@@ -669,9 +669,9 @@
struct vframe *frame = NULL, *enter_last_frame = NULL;
struct av_sync_session *avsync = (struct av_sync_session *)sync;
int toggle_cnt = 0;
- uint32_t systime;
+ uint32_t systime = 0;
bool pause_pts_reached = false;
- uint32_t interval;
+ uint32_t interval = 0;
if (avsync->type == AV_SYNC_TYPE_VIDEO &&
avsync->mode == AV_SYNC_MODE_VIDEO_MONO)
@@ -834,7 +834,7 @@
static uint64_t time_diff (struct timespec *b, struct timespec *a)
{
- return (b->tv_sec - a->tv_sec)*1000000 + (b->tv_nsec/1000 - a->tv_nsec/1000);
+ return (uint64_t)(b->tv_sec - a->tv_sec)*1000000 + (b->tv_nsec/1000 - a->tv_nsec/1000);
}
static bool frame_expire(struct av_sync_session* avsync,
@@ -1603,7 +1603,7 @@
lseek(fd, 0, SEEK_SET);
- nread = read(fd, buf, sizeof(buf));
+ nread = read(fd, buf, sizeof(buf)-1);
if (nread <= 0) {
log_error("read error");
goto err;
@@ -1769,7 +1769,7 @@
ret = queue_item(avsync->frame_q, frame);
if (ret)
- log_error("%s queue fail:%d", ret);
+ log_error("queue fail:%d", ret);
log_debug("[%d]push %llu, QNum=%d", avsync->session_id, frame->mts, queue_size(avsync->frame_q));
return ret;
}
@@ -1820,8 +1820,8 @@
if (avsync->last_frame) {
if (enter_last_frame != avsync->last_frame)
- log_debug("[%d]pop %llu", avsync->session_id, avsync->last_frame->pts);
- log_trace("[%d]pop=%llu, system=%llu, diff %d(ms), QNum=%d", avsync->session_id,
+ log_debug("[%d]pop %lu", avsync->session_id, avsync->last_frame->pts);
+ log_trace("[%d]pop=%llu, system=%llu, diff %llu(ms), QNum=%d", avsync->session_id,
avsync->last_frame->mts,
systime, (systime - avsync->last_frame->mts) / 1000000,
queue_size(avsync->frame_q));
diff --git a/src/msync_util.c b/src/msync_util.c
index 86612ba..59b44af 100644
--- a/src/msync_util.c
+++ b/src/msync_util.c
@@ -356,7 +356,7 @@
pcr.mono_clock = mono_clock;
rc = ioctl(fd, AMSYNCS_IOC_SET_PCR, &pcr);
if (rc)
- log_error("session[%d] set pcr %u errno:%d", fd, pcr, errno);
+ log_error("session[%d] set pcr.pts %u errno:%d", fd, pcr.pts, errno);
return rc;
}
@@ -368,7 +368,7 @@
rc = ioctl(fd, AMSYNCS_IOC_GET_PCR, &pcr);
if (rc)
- log_error("session[%d] set pcr %u errno:%d", fd, pcr, errno);
+ log_error("session[%d] get pcr.pts %u errno:%d", fd, pcr.pts, errno);
else {
*pts = pcr.pts;
*mono_clock = pcr.mono_clock;
@@ -436,8 +436,7 @@
fd = open(path, O_RDONLY);
if (fd >= 0) {
memset(valstr, 0, 64);
- read(fd, valstr, 64 - 1);
- valstr[strnlen(valstr, sizeof(valstr))] = '\0';
+ (void)read(fd, valstr, 64 - 1);
close(fd);
} else {
log_error("unable to open file %s\n", path);