fix(nxp) coverity issues

Signed-off-by: Cosmin-Daniel Radu <cosmin.radu_1@nxp.com>
This commit is contained in:
Cosmin-Daniel Radu
2025-05-07 09:54:29 +03:00
committed by Gabor Kiss-Vamosi
parent 2d0f6be1d0
commit a1070903b0
5 changed files with 26 additions and 21 deletions
+15 -15
View File
@@ -49,7 +49,7 @@ static const uint16_t TperDegree[90] = {
/* intermediate arc params */
typedef struct _vg_arc {
int32_t angle; /* angle <90deg */
uint32_t angle; /* angle <90deg */
int32_t quarter; /* 0-3 counter-clockwise */
int32_t rad; /* radius */
int32_t p0x; /* point P0 */
@@ -140,11 +140,11 @@ static void _copy_arc(vg_arc * dst, vg_arc * src)
/**
* Rotate the point according given rotation angle rotation center is 0,0
*/
static void _rotate_point(int32_t angle, int32_t * x, int32_t * y)
static void _rotate_point(int16_t angle, int32_t * x, int32_t * y)
{
int32_t ori_x = *x;
int32_t ori_y = *y;
int16_t alpha = (int16_t)angle;
int16_t alpha = angle;
*x = ((lv_trigo_cos(alpha) * ori_x) / LV_TRIGO_SIN_MAX) - ((lv_trigo_sin(alpha) * ori_y) / LV_TRIGO_SIN_MAX);
*y = ((lv_trigo_sin(alpha) * ori_x) / LV_TRIGO_SIN_MAX) + ((lv_trigo_cos(alpha) * ori_y) / LV_TRIGO_SIN_MAX);
}
@@ -269,7 +269,7 @@ static uint16_t _get_bez_t_from_pos(float pt, cubic_cont_pt cp, bool dec)
* Gives relative coords of the control points
* for the sub-arc starting at angle with given angle span
*/
static void _get_subarc_control_points(vg_arc * arc, int32_t span)
static void _get_subarc_control_points(vg_arc * arc, uint32_t span)
{
vg_arc fullarc = {0};
fullarc.angle = arc->angle;
@@ -427,10 +427,10 @@ static void _get_arc_control_points(vg_arc * arc, bool start)
* center: (in) the center of the circle in draw coordinates
* cw: (in) true if arc is clockwise
*/
static void _add_split_arc_path(int32_t * arc_path, int * pidx, vg_arc * q_arc, const lv_point_t * center, bool cw)
static void _add_split_arc_path(int32_t * arc_path, uint32_t * pidx, vg_arc * q_arc, const lv_point_t * center, bool cw)
{
/* assumes first control point already in array arc_path[] */
int idx = *pidx;
uint32_t idx = *pidx;
if(cw) {
#if BEZIER_DBG_CONTROL_POINTS
arc_path[idx++] = VLC_OP_LINE;
@@ -477,15 +477,15 @@ static void _add_split_arc_path(int32_t * arc_path, int * pidx, vg_arc * q_arc,
*pidx = idx;
}
static void _add_arc_path(int32_t * arc_path, int * pidx, int32_t radius,
static void _add_arc_path(int32_t * arc_path, uint32_t * pidx, uint32_t radius,
int32_t start_angle, int32_t end_angle, const lv_point_t * center, bool cw)
{
/* set number of arcs to draw */
vg_arc q_arc;
int32_t start_arc_angle = start_angle % 90;
int32_t end_arc_angle = end_angle % 90;
int32_t inv_start_arc_angle = (start_arc_angle > 0) ? (90 - start_arc_angle) : 0;
int32_t nbarc = (end_angle - start_angle - inv_start_arc_angle - end_arc_angle) / 90;
uint32_t start_arc_angle = start_angle % 90;
uint32_t end_arc_angle = end_angle % 90;
uint32_t inv_start_arc_angle = (start_arc_angle > 0) ? (90 - start_arc_angle) : 0;
uint32_t nbarc = (end_angle - start_angle - inv_start_arc_angle - end_arc_angle) / 90;
q_arc.rad = radius;
/* handle special case of start & end point in the same quarter */
@@ -508,7 +508,7 @@ static void _add_arc_path(int32_t * arc_path, int * pidx, int32_t radius,
_add_split_arc_path(arc_path, pidx, &q_arc, center, cw);
}
/* full arcs */
for(int32_t q = 0; q < nbarc ; q++) {
for(uint32_t q = 0; q < nbarc ; q++) {
q_arc.quarter = (q + ((start_angle + 89) / 90)) % 4;
q_arc.angle = 90;
/* get cubic points relative to center */
@@ -565,8 +565,8 @@ static void _vglite_draw_arc(vglite_draw_task_t * vglite_task, const lv_point_t
vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t));
LV_ASSERT(path != NULL);
vglite_task->path = path;
uint16_t start_angle = dsc->start_angle;
uint16_t end_angle = dsc->end_angle;
int16_t start_angle = dsc->start_angle;
int16_t end_angle = dsc->end_angle;
/* be sure end_angle > start_angle */
if(end_angle < start_angle)
@@ -586,7 +586,7 @@ static void _vglite_draw_arc(vglite_draw_task_t * vglite_task, const lv_point_t
if(width > radius)
width = radius;
int pidx = 0;
uint32_t pidx = 0;
int32_t cp_x, cp_y; /* control point coords */
/* first control point of curve */
+1 -1
View File
@@ -229,7 +229,7 @@ static void _vglite_draw_border(vglite_draw_task_t * vglite_task, const lv_area_
VGLITE_CHECK_ERROR(vg_lite_disable_scissor());
}
else {
for(int i = 0; i < scissoring_rects.num_rect; i++) {
for(uint32_t i = 0; i < scissoring_rects.num_rect; i++) {
VGLITE_CHECK_ERROR(vg_lite_set_scissor(scissoring_rects.rect[i].x, scissoring_rects.rect[i].y,
scissoring_rects.rect[i].x + scissoring_rects.rect[i].width,
scissoring_rects.rect[i].y + scissoring_rects.rect[i].height));
+1 -1
View File
@@ -215,7 +215,7 @@ static void _vglite_draw_rect(vglite_draw_task_t * vglite_task, const lv_area_t
lv_color32_t col32[LV_GRADIENT_MAX_STOPS];
/* Gradient setup */
vg_lite_uint32_t cnt = LV_MAX(dsc->grad.stops_count, LV_GRADIENT_MAX_STOPS);
vg_lite_uint32_t cnt = LV_MIN(dsc->grad.stops_count, LV_GRADIENT_MAX_STOPS);
lv_opa_t opa;
for(uint8_t i = 0; i < cnt; i++) {
+8 -3
View File
@@ -128,12 +128,17 @@ static void _draw_vglite_letter(lv_draw_task_t * t, lv_draw_glyph_dsc_t * glyph_
lv_area_move(&blend_area, -layer->buf_area.x1, -layer->buf_area.y1);
const bool static_bitmap = lv_font_has_static_bitmap(glyph_draw_dsc->g->resolved_font);
const void * mask_buf;
const lv_draw_buf_t * draw_buf;
const void * mask_buf = NULL;
const lv_draw_buf_t * draw_buf = NULL;
uint32_t mask_stride;
if(!static_bitmap) {
draw_buf = lv_font_get_glyph_bitmap(glyph_draw_dsc->g, glyph_draw_dsc->_draw_buf);
mask_buf = draw_buf->data;
if(draw_buf != NULL) {
mask_buf = draw_buf->data;
}
else {
return;
}
mask_stride = draw_buf->header.stride;
}
else {
@@ -160,7 +160,7 @@ static void _vglite_draw_triangle(vglite_draw_task_t * vglite_task, const lv_are
lv_color32_t col32[LV_GRADIENT_MAX_STOPS];
/* Gradient Setup */
vg_lite_uint32_t cnt = LV_MAX(dsc->grad.stops_count, LV_GRADIENT_MAX_STOPS);
vg_lite_uint32_t cnt = LV_MIN(dsc->grad.stops_count, LV_GRADIENT_MAX_STOPS);
lv_opa_t opa;
for(uint8_t i = 0; i < cnt; i++) {