fix warning and ub (#3089)

This commit is contained in:
zxkmm
2026-03-14 00:51:15 +08:00
committed by GitHub
parent 5aecd4097e
commit b273165a0c
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -294,8 +294,8 @@ bool BtnGridView::set_highlighted(int32_t new_value, bool force_update) {
}
// Normalize offset to show maximum items when count decreased
if (offset + displayed_max > item_count && item_count > 0) {
if (item_count >= displayed_max) {
if (item_count > 0 && offset + displayed_max > static_cast<size_t>(item_count)) {
if (static_cast<size_t>(item_count) >= displayed_max) {
offset = item_count - displayed_max;
} else {
offset = 0;
@@ -342,7 +342,7 @@
// ============================================================================
uint8_t fpga_register_read(uint8_t reg) {
if (reg == 0 || reg > 5) return;
if (reg == 0 || reg > 5) return 0xFF;
ssp1_set_mode_ice40();
uint8_t val = fpga_spi_read(reg);