Skip to content

feat(translation): add arg checks to public functions#10208

Open
axos88 wants to merge 3 commits into
masterfrom
feat-add-lv-check-arg-to-core-lv_translation
Open

feat(translation): add arg checks to public functions#10208
axos88 wants to merge 3 commits into
masterfrom
feat-add-lv-check-arg-to-core-lv_translation

Conversation

@axos88

@axos88 axos88 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Add LV_CHECK_ARG to all public API functions in lv_translation.c. Also fixes lv_translation_get_language_index which returned 0 (a valid index) instead of -1 on error.

Public API audit

Function Parameters Action Reason
lv_translation_init(void) No check needed No pointer/numeric params
lv_translation_deinit(void) No check needed No pointer/numeric params
lv_translation_pack_t * lv_translation_add_static(const char * const * languages, const char * const * tags, const char * const * const * translations) languages Added (replaced LV_ASSERT_NULL) Converts crash to graceful return
tags Added (replaced LV_ASSERT_NULL) Converts crash to graceful return
translations Added (replaced LV_ASSERT_NULL) Converts crash to graceful return
lv_translation_add_dynamic(void) No check needed No pointer/numeric params
lv_translation_set_language(const char * lang) lang Added No guard existed on master
lv_translation_get_language(void) No check needed No pointer/numeric params
lv_translation_get(const char * tag) tag Added No guard existed on master
lv_tr(const char * tag) (inline) tag Delegates to lv_translation_get Inline wrapper; check covered by callee
lv_translation_add_language(lv_translation_pack_t * pack, const char * lang) pack
lang
Added
Added
No guard existed on master
No guard existed on master
lv_translation_get_language_index(lv_translation_pack_t * pack, const char * lang_name) pack
lang_name
Added + Fixed
Added + Fixed
No guard existed on master; returns -1 (not 0) so callers can detect error
No guard existed on master; returns -1 (not 0) so callers can detect error
lv_translation_add_tag(lv_translation_pack_t * pack, const char * tag_name) pack
tag_name
Added
Added
No guard existed on master
No guard existed on master
lv_translation_set_tag_translation(lv_translation_pack_t * pack, lv_translation_tag_dsc_t * tag, uint32_t lang_idx, const char * trans) pack
tag
trans
lang_idx
Added
Added
Added
Pre-existing
No guard existed on master
No guard existed on master
No guard existed on master
Bounds-checked inline on master; kept as-is

Generated with Claude Code

Copilot AI review requested due to automatic review settings May 28, 2026 19:38

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/others/translation/lv_translation.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@axos88 axos88 changed the title feat(core): add lv_check_arg to public functions in lv_translation feat(others): add lv_check_arg to public functions in lv_translation May 29, 2026
@axos88 axos88 marked this pull request as draft May 29, 2026 10:04
@axos88 axos88 marked this pull request as ready for review June 3, 2026 14:49

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@AndreCostaaa AndreCostaaa changed the title feat(others): add lv_check_arg to public functions in lv_translation feat(translation): add arg checks to public functions Jun 15, 2026
AndreCostaaa
AndreCostaaa previously approved these changes Jun 15, 2026
@AndreCostaaa AndreCostaaa marked this pull request as draft June 15, 2026 12:12
@AndreCostaaa AndreCostaaa marked this pull request as ready for review June 15, 2026 12:29

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

axos88 and others added 2 commits June 24, 2026 11:07
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… NULL args

The previous LV_CHECK_ARG guards returned 0 on NULL pack or lang_name,
but 0 is a valid language index. The documented "not found" sentinel for
this function is -1, so use that consistently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@axos88 axos88 force-pushed the feat-add-lv-check-arg-to-core-lv_translation branch from 5c3329a to 03df37e Compare June 24, 2026 09:07
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Hi 👋, thank you for your PR!

We've run benchmarks in an emulated environment. Here are the results:

ARM Emulated 32b - lv_conf_perf32b

Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
All scenes avg. 28 37 7 7 0
Detailed Results Per Scene
Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
Empty screen 11 33 0 0 0
Moving wallpaper 2 33 1 1 0
Single rectangle 0 50 0 0 0
Multiple rectangles 0 33 0 0 0
Multiple RGB images 0 39 0 0 0
Multiple ARGB images 11 (-2) 40 (+1) 3 (-1) 3 (-1) 0
Rotated ARGB images 54 (-2) 44 15 15 0
Multiple labels 8 (-1) 35 (+2) 0 0 0
Screen sized text 87 (+3) 46 18 18 0
Multiple arcs 41 (-1) 33 (-1) 7 7 0
Containers 4 38 (+1) 0 0 0
Containers with overlay 88 21 44 44 0
Containers with opa 15 (+7) 38 (+1) 1 1 0
Containers with opa_layer 19 (-1) 34 5 5 0
Containers with scrolling 43 (-1) 44 (-1) 12 12 0
Widgets demo 72 40 (+1) 16 16 0
All scenes avg. 28 37 7 7 0

ARM Emulated 64b - lv_conf_perf64b

Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
All scenes avg. 24 37 6 6 0
Detailed Results Per Scene
Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
Empty screen 11 33 0 0 0
Moving wallpaper 2 33 0 0 0
Single rectangle 0 50 0 0 0
Multiple rectangles 0 35 0 0 0
Multiple RGB images 0 39 0 0 0
Multiple ARGB images 12 41 0 0 0
Rotated ARGB images 29 34 9 9 0
Multiple labels 2 33 0 0 0
Screen sized text 83 46 18 18 0
Multiple arcs 31 33 7 7 0
Containers 1 37 0 0 0
Containers with overlay 89 22 42 42 0
Containers with opa 13 36 0 0 0
Containers with opa_layer 9 36 2 2 0
Containers with scrolling 48 49 12 12 0
Widgets demo 67 40 15 15 0
All scenes avg. 24 37 6 6 0

Disclaimer: These benchmarks were run in an emulated environment using QEMU with instruction counting mode.
The timing values represent relative performance metrics within this specific virtualized setup and should
not be interpreted as absolute real-world performance measurements. Values are deterministic and useful for
comparing different LVGL features and configurations, but may not correlate directly with performance on
physical hardware. The measurements are intended for comparative analysis only.


🤖 This comment was automatically generated by a bot.

Add test_null_arguments_are_rejected exercising the LV_CHECK_ARG NULL
guards in lv_translation_add_language, lv_translation_get_language_index,
lv_translation_add_tag and lv_translation_set_tag_translation.
@axos88 axos88 enabled auto-merge (squash) June 26, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants