From 3d047de1d46e535e71361131fa290bf84b57ef8b Mon Sep 17 00:00:00 2001 From: Yanjun Liao Date: Wed, 29 Oct 2025 10:12:02 +0800 Subject: [PATCH] fix[mpp]: Fix c89 build error Change-Id: I648e78e4b271e914225f848309290e749fdd5176 Signed-off-by: Yanjun Liao --- mpp/base/mpp_buf_slot.c | 3 ++- mpp/base/mpp_task_impl.c | 3 ++- mpp/codec/mpp_dec_no_thread.c | 6 ++++-- mpp/codec/mpp_dec_normal.c | 7 +++++-- osal/mpp_soc.c | 3 ++- osal/mpp_thread.c | 7 +++++-- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/mpp/base/mpp_buf_slot.c b/mpp/base/mpp_buf_slot.c index 2b1db03c..3ca80509 100644 --- a/mpp/base/mpp_buf_slot.c +++ b/mpp/base/mpp_buf_slot.c @@ -805,6 +805,7 @@ static void clear_slots_impl(MppBufSlotsImpl *impl) MPP_RET mpp_buf_slot_init(MppBufSlots *slots) { MppBufSlotsImpl *impl; + RK_U32 i; if (!slots) { mpp_err_f("found NULL input\n"); @@ -829,7 +830,7 @@ MPP_RET mpp_buf_slot_init(MppBufSlots *slots) mpp_mutex_init(&impl->lock); - for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(impl->queue); i++) { + for (i = 0; i < MPP_ARRAY_ELEMS(impl->queue); i++) { INIT_LIST_HEAD(&impl->queue[i]); } diff --git a/mpp/base/mpp_task_impl.c b/mpp/base/mpp_task_impl.c index 455bfa90..94bc2e50 100644 --- a/mpp/base/mpp_task_impl.c +++ b/mpp/base/mpp_task_impl.c @@ -480,6 +480,7 @@ MPP_RET mpp_task_queue_setup(MppTaskQueue queue, RK_S32 task_count) MPP_RET mpp_task_queue_deinit(MppTaskQueue queue) { MppTaskQueueImpl *p = (MppTaskQueueImpl *)queue; + RK_S32 i; if (!p) { mpp_err_f("found NULL input queue\n"); @@ -493,7 +494,7 @@ MPP_RET mpp_task_queue_deinit(MppTaskQueue queue) mpp_cond_signal(&p->info[MPP_OUTPUT_PORT].cond); if (p->tasks) { - for (RK_S32 i = 0; i < p->task_count; i++) { + for (i = 0; i < p->task_count; i++) { MppMeta meta = p->tasks[i].meta; /* we must ensure that all task return to init status */ diff --git a/mpp/codec/mpp_dec_no_thread.c b/mpp/codec/mpp_dec_no_thread.c index 475c5d8d..95ad8102 100644 --- a/mpp/codec/mpp_dec_no_thread.c +++ b/mpp/codec/mpp_dec_no_thread.c @@ -27,6 +27,7 @@ MPP_RET mpp_dec_decode(MppDec ctx, MppPacket packet) MppPacket input = dec->mpp_pkt_in; size_t stream_size = 0; RK_S32 output = 0; + RK_U32 i; mpp_mutex_cond_lock(cmd_lock); @@ -322,7 +323,7 @@ MPP_RET mpp_dec_decode(MppDec ctx, MppPacket packet) if (task_dec->output >= 0) mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT); - for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { + for (i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { RK_S32 index = task_dec->refer[i]; if (index >= 0) mpp_buf_slot_clr_flag(frame_slots, index, SLOT_HAL_INPUT); @@ -351,6 +352,7 @@ MPP_RET mpp_dec_reset_no_thread(MppDecImpl *dec) MppMutexCond *cmd_lock = &dec->cmd_lock; HalDecTask *task_dec = &task->info.dec; RK_S32 index; + RK_U32 i; mpp_mutex_cond_lock(cmd_lock); @@ -374,7 +376,7 @@ MPP_RET mpp_dec_reset_no_thread(MppDecImpl *dec) if (task->status.task_parsed_rdy) { mpp_log("task no send to hal que must clr current frame hal status\n"); mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT); - for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { + for (i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { index = task_dec->refer[i]; if (index >= 0) mpp_buf_slot_clr_flag(frame_slots, index, SLOT_HAL_INPUT); diff --git a/mpp/codec/mpp_dec_normal.c b/mpp/codec/mpp_dec_normal.c index 1289fdb6..34c6703f 100644 --- a/mpp/codec/mpp_dec_normal.c +++ b/mpp/codec/mpp_dec_normal.c @@ -156,6 +156,8 @@ static RK_U32 reset_parser_thread(Mpp *mpp, DecTask *task) // do parser reset process { RK_S32 index; + RK_U32 i; + task->status.curr_task_rdy = 0; task->status.prev_task_rdy = 1; task_dec->valid = 0; @@ -172,7 +174,7 @@ static RK_U32 reset_parser_thread(Mpp *mpp, DecTask *task) if (task_dec->output >= 0) mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT); - for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { + for (i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { index = task_dec->refer[i]; if (index >= 0) mpp_buf_slot_clr_flag(frame_slots, index, SLOT_HAL_INPUT); @@ -776,6 +778,7 @@ void *mpp_dec_hal_thread(void *data) HalTaskHnd task = NULL; HalTaskInfo task_info; HalDecTask *task_dec = &task_info.dec; + RK_U32 i; mpp_clock_start(dec->clocks[DEC_HAL_TOTAL]); @@ -884,7 +887,7 @@ void *mpp_dec_hal_thread(void *data) if (task_dec->output >= 0) mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT); - for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { + for (i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { RK_S32 index = task_dec->refer[i]; if (index >= 0) mpp_buf_slot_clr_flag(frame_slots, index, SLOT_HAL_INPUT); diff --git a/osal/mpp_soc.c b/osal/mpp_soc.c index 4063d9e1..e1c52f85 100644 --- a/osal/mpp_soc.c +++ b/osal/mpp_soc.c @@ -1030,6 +1030,7 @@ static const MppSocInfo mpp_soc_default = { static void read_soc_name(char *name, rk_s32 size) { const char *path = "/proc/device-tree/compatible"; + char *ptr = NULL; rk_s32 fd = open(path, O_RDONLY); if (fd < 0) { @@ -1042,7 +1043,7 @@ static void read_soc_name(char *name, rk_s32 size) if (soc_name_len > 0) { name[soc_name_len] = '\0'; /* replacing the termination character to space */ - for (char *ptr = name;; ptr = name) { + for (ptr = name;; ptr = name) { ptr += strnlen(name, size); if (ptr >= name + soc_name_len - 1) break; diff --git a/osal/mpp_thread.c b/osal/mpp_thread.c index a8cbcb89..8791cd5d 100644 --- a/osal/mpp_thread.c +++ b/osal/mpp_thread.c @@ -22,6 +22,7 @@ static rk_u32 thread_debug = 0; MppThread *mpp_thread_create(MppThreadFunc func, void *ctx, const char *name) { MppThread *thread = mpp_malloc(MppThread, 1); + int i; if (thread) { thread->func = func; @@ -38,7 +39,7 @@ MppThread *mpp_thread_create(MppThreadFunc func, void *ctx, const char *name) } else { snprintf(thread->name, THREAD_NAME_LEN, "MppThread"); } - for (int i = 0; i < THREAD_SIGNAL_BUTT; i++) { + for (i = 0; i < THREAD_SIGNAL_BUTT; i++) { mpp_mutex_cond_init(&thread->mutex_cond[i]); } } @@ -243,11 +244,13 @@ void mpp_thread_init(MppThread *thread, MppThreadFunc func, void *ctx, const cha { thread->func = func; thread->ctx = ctx; + int i; + if (name) { strncpy(thread->name, name, THREAD_NAME_LEN - 1); thread->name[THREAD_NAME_LEN - 1] = '\0'; } - for (int i = 0; i < THREAD_SIGNAL_BUTT; i++) { + for (i = 0; i < THREAD_SIGNAL_BUTT; i++) { mpp_mutex_cond_init(&thread->mutex_cond[i]); thread->thd_status[i] = MPP_THREAD_UNINITED; }