Skip to content

fix(m5stack_tab5): don't return NULL from int bsp_get_board_version() - #808

Open
vikramdattu wants to merge 1 commit into
espressif:masterfrom
vikramdattu:fix/tab5-board-version-int-conversion
Open

fix(m5stack_tab5): don't return NULL from int bsp_get_board_version()#808
vikramdattu wants to merge 1 commit into
espressif:masterfrom
vikramdattu:fix/tab5-board-version-int-conversion

Conversation

@vikramdattu

@vikramdattu vikramdattu commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

bsp_get_board_version() in bsp/m5stack_tab5/src/bsp_display.c returns int, but uses BSP_ERROR_CHECK_RETURN_NULL. When CONFIG_BSP_ERROR_CHECK is disabled, that macro expands to return NULL;, so the file fails to compile with -Wint-conversion (an error with current toolchains):

bsp_display.c:138:5: error: returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]

Any project that sets CONFIG_BSP_ERROR_CHECK=n (return-error-code style instead of abort) cannot build the Tab5 BSP.

Fix: use BSP_ERROR_CHECK(x, 0). With CONFIG_BSP_ERROR_CHECK enabled the behaviour is unchanged (ESP_ERROR_CHECK); with it disabled the function returns 0 ("version unknown") and, since board_ver only caches values > 0, the probe retries on the next call.

Hit in an app build (ESP-IDF v5.5.4, esp32p4, m5stack_tab5 1.2.0~1, CONFIG_BSP_ERROR_CHECK=n). Verified the pre-fix code reproduces the exact error under -Werror=int-conversion and the fixed code compiles clean.


Note

Low Risk
Localized BSP display/touch init fix and clearer error handling; behavior unchanged when error-check abort mode is enabled.

Overview
Fixes a build break when CONFIG_BSP_ERROR_CHECK=n: bsp_get_board_version() now uses BSP_ERROR_CHECK(..., 0) instead of BSP_ERROR_CHECK_RETURN_NULL, so it no longer emits return NULL from an int function (-Wint-conversion).

Display and touch setup cache the board version once per path and fail with ESP_ERR_NOT_SUPPORTED if probing did not yield version 1 or 2, instead of calling bsp_get_board_version() repeatedly and branching with separate == 2 checks.

Reviewed by Cursor Bugbot for commit 8789c23. Bugbot is set up for automated code reviews on this repo. Configure here.

@vikramdattu
vikramdattu force-pushed the fix/tab5-board-version-int-conversion branch from d3b18c3 to 7bd9b3f Compare July 27, 2026 12:29

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7bd9b3f. Configure here.

Comment thread bsp/m5stack_tab5/src/bsp_display.c
BSP_ERROR_CHECK_RETURN_NULL expands to 'return NULL' when
CONFIG_BSP_ERROR_CHECK is disabled, which fails to compile with
-Wint-conversion inside the int-returning bsp_get_board_version().
Use BSP_ERROR_CHECK(x, 0) instead: abort-style behaviour is unchanged
when CONFIG_BSP_ERROR_CHECK is enabled, and with it disabled the
function returns 0 (version unknown) so the probe retries on the next
call.

Callers now fetch the version once and fail with ESP_ERR_NOT_SUPPORTED
on an unknown version instead of silently skipping panel/touch driver
creation.
@vikramdattu
vikramdattu force-pushed the fix/tab5-board-version-int-conversion branch from 7bd9b3f to 8789c23 Compare July 27, 2026 12:40
@espzav

espzav commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

@vikramdattu Thank you for this fix. You are right.
We are waiting for this PR: #804 it can fix this issue too. But there is still discussion.

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.

2 participants