vout_serve: code coverity fix

PD#168799: vout_serve: code coverity fix

Change-Id: Id5358f4adc791980b14e2c22eff3443e9601a90e
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
This commit is contained in:
Evoke Zhang
2018-06-21 13:23:55 +08:00
committed by Yixun Lan
parent fa6fba6130
commit d76dd736eb
2 changed files with 56 additions and 27 deletions

View File

@@ -157,6 +157,11 @@ void vout_func_set_state(int index, enum vmode_e mode)
p_module = &vout2_module;
#endif
if (p_module == NULL) {
VOUTERR("vout%d: %s: vout_module is NULL\n", index, __func__);
mutex_unlock(&vout_mutex);
return;
}
list_for_each_entry(p_server, &p_module->vout_server_list, list) {
if (p_server->op.vmode_is_supported == NULL) {
p_server->op.disable(mode);
@@ -192,33 +197,32 @@ void vout_func_update_viu(int index)
mutex_lock(&vout_mutex);
if (index == 1)
if (index == 1) {
p_module = &vout_module;
#ifdef CONFIG_AMLOGIC_VOUT2_SERVE
else if (index == 2)
p_module = &vout2_module;
#endif
p_server = p_module->curr_vout_server;
if (p_server->op.get_vinfo)
vinfo = p_server->op.get_vinfo();
if (vinfo == NULL)
vinfo = get_invalid_vinfo(index);
switch (index) {
case 1:
mux_bit = 0;
clk_sel = 0;
break;
case 2:
} else if (index == 2) {
#ifdef CONFIG_AMLOGIC_VOUT2_SERVE
p_module = &vout2_module;
mux_bit = 2;
clk_sel = 1;
break;
default:
break;
#endif
}
if (p_module == NULL) {
VOUTERR("vout%d: %s: vout_module is NULL\n", index, __func__);
mutex_unlock(&vout_mutex);
return;
}
p_server = p_module->curr_vout_server;
if (p_server) {
if (p_server->op.get_vinfo)
vinfo = p_server->op.get_vinfo();
}
if (vinfo == NULL)
vinfo = get_invalid_vinfo(index);
mux_sel = vinfo->viu_mux;
switch (mux_sel) {
case VIU_MUX_ENCL:
@@ -262,6 +266,12 @@ int vout_func_set_vmode(int index, enum vmode_e mode)
else if (index == 2)
p_module = &vout2_module;
#endif
if (p_module == NULL) {
VOUTERR("vout%d: %s: vout_module is NULL\n", index, __func__);
mutex_unlock(&vout_mutex);
return -1;
}
ret = p_module->curr_vout_server->op.set_vmode(mode);
mutex_unlock(&vout_mutex);
@@ -301,6 +311,11 @@ enum vmode_e vout_func_validate_vmode(int index, char *name)
p_module = &vout2_module;
#endif
if (p_module == NULL) {
VOUTERR("vout%d: %s: vout_module is NULL\n", index, __func__);
mutex_unlock(&vout_mutex);
return VMODE_MAX;
}
list_for_each_entry(p_server, &p_module->vout_server_list, list) {
/* check state for another vout */
if (p_server->op.get_state) {
@@ -490,6 +505,10 @@ int vout_func_vout_shutdown(int index)
p_module = &vout2_module;
#endif
if (p_module == NULL) {
VOUTERR("vout%d: %s: vout_module is NULL\n", index, __func__);
return -1;
}
list_for_each_entry(p_server, &p_module->vout_server_list, list) {
if (p_server->op.vout_shutdown)
ret = p_server->op.vout_shutdown();
@@ -531,6 +550,11 @@ int vout_func_vout_register_server(int index,
p_module = &vout2_module;
#endif
if (p_module == NULL) {
VOUTERR("vout%d: %s: vout_module is NULL\n", index, __func__);
mutex_unlock(&vout_mutex);
return -1;
}
list_for_each(p_iter, &p_module->vout_server_list) {
p_server = list_entry(p_iter, struct vout_server_s, list);
@@ -570,6 +594,11 @@ int vout_func_vout_unregister_server(int index,
p_module = &vout2_module;
#endif
if (p_module == NULL) {
VOUTERR("vout%d: %s: vout_module is NULL\n", index, __func__);
mutex_unlock(&vout_mutex);
return -1;
}
list_for_each_entry(p_server, &p_module->vout_server_list, list) {
if (p_server->name && mem_server->name &&
(strcmp(p_server->name, mem_server->name) == 0)) {

View File

@@ -263,15 +263,15 @@ static int set_vout_init_mode(void)
char init_mode_str[VMODE_NAME_LEN_MAX];
int ret = 0;
strncpy(init_mode_str, vout_mode_uboot, VMODE_NAME_LEN_MAX);
snprintf(init_mode_str, VMODE_NAME_LEN_MAX, "%s", vout_mode_uboot);
vout_init_vmode = validate_vmode(vout_mode_uboot);
if (vout_init_vmode >= VMODE_MAX) {
VOUTERR("no matched vout_init mode %s, force to invalid\n",
vout_mode_uboot);
nulldisp_index = 1;
vout_init_vmode = nulldisp_vinfo[nulldisp_index].mode;
strncpy(init_mode_str, nulldisp_vinfo[nulldisp_index].name,
VMODE_NAME_LEN_MAX);
snprintf(init_mode_str, VMODE_NAME_LEN_MAX, "%s",
nulldisp_vinfo[nulldisp_index].name);
}
last_vmode = vout_init_vmode;
@@ -800,18 +800,18 @@ static int refresh_tvout_mode(void)
hpd_state = vout_get_hpd_state();
if (hpd_state) {
cur_vmode = validate_vmode(hdmimode);
strncpy(cur_mode_str, hdmimode, VMODE_NAME_LEN_MAX);
snprintf(cur_mode_str, VMODE_NAME_LEN_MAX, "%s", hdmimode);
} else {
cur_vmode = validate_vmode(cvbsmode);
strncpy(cur_mode_str, cvbsmode, VMODE_NAME_LEN_MAX);
snprintf(cur_mode_str, VMODE_NAME_LEN_MAX, "%s", cvbsmode);
}
if (cur_vmode >= VMODE_MAX) {
VOUTERR("%s: no matched cur_mode: %s, force to invalid\n",
__func__, cur_mode_str);
nulldisp_index = 1;
cur_vmode = nulldisp_vinfo[nulldisp_index].mode;
strncpy(cur_mode_str, nulldisp_vinfo[nulldisp_index].name,
VMODE_NAME_LEN_MAX);
snprintf(cur_mode_str, VMODE_NAME_LEN_MAX, "%s",
nulldisp_vinfo[nulldisp_index].name);
}
/* not box platform */