mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-02 18:26:11 +00:00
style(ui): sprintf → snprintf with sizeof in UI render paths
Mechanical sweep across UITask.cpp and SettingsScreen.h. All current format strings already fit their buffers, but a future format change would silently overflow with sprintf. snprintf with sizeof makes the buffer bound explicit and traceable to the array declaration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
559fe86f20
commit
e16ecbd690
@@ -374,7 +374,7 @@ class SettingsScreen : public UIScreen {
|
||||
} else if (item == TX_POWER) {
|
||||
display.print("TX Pwr");
|
||||
char buf[8];
|
||||
sprintf(buf, "%ddBm", p ? p->tx_power_dbm : 0);
|
||||
snprintf(buf, sizeof(buf),"%ddBm", p ? p->tx_power_dbm : 0);
|
||||
display.setCursor(display.valCol(), y);
|
||||
display.print(buf);
|
||||
#if AUTO_OFF_MILLIS > 0
|
||||
@@ -397,8 +397,8 @@ class SettingsScreen : public UIScreen {
|
||||
display.print("TimeZone");
|
||||
char buf[8];
|
||||
int8_t tz = p ? p->tz_offset_hours : 0;
|
||||
if (tz >= 0) sprintf(buf, "UTC+%d", (int)tz);
|
||||
else sprintf(buf, "UTC%d", (int)tz);
|
||||
if (tz >= 0) snprintf(buf, sizeof(buf),"UTC+%d", (int)tz);
|
||||
else snprintf(buf, sizeof(buf),"UTC%d", (int)tz);
|
||||
display.setCursor(display.valCol(), y);
|
||||
display.print(buf);
|
||||
} else if (item == LOW_BAT) {
|
||||
|
||||
Reference in New Issue
Block a user