Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/hal/support.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@ void hal_identify(void) {
vid_thread = i6_video_thread;

if (file = fopen("/proc/cmdline", "r")) {
fgets(line, 200, file);
char *remain, *capacity = strstr(line, "LX_MEM=");
memory = (short)(strtol(capacity + 7, &remain, 16) >> 20);
char *remain, *capacity = NULL;
if (fgets(line, 200, file))
capacity = strstr(line, "LX_MEM=");
if (capacity)
memory = (short)(strtol(capacity + 7, &remain, 16) >> 20);
fclose(file);
}

if (file = fopen("/sys/devices/soc0/machine", "r")) {
fgets(line, 200, file);
char *board = strstr(line, "SSC");
strncpy(package, board + 4, 3);
char *board = NULL;
if (fgets(line, 200, file))
board = strstr(line, "SSC");
/* package takes board[4..6], so the match must be that long */
if (board && strlen(board) >= 7)
strncpy(package, board + 4, 3);
fclose(file);
}

Expand Down Expand Up @@ -338,9 +343,11 @@ float hal_temperature_read(void) {
FILE* file;
char line[20] = {0};
if (file = fopen("/sys/class/mstar/msys/TEMP_R", "r")) {
fgets(line, 20, file);
char *remain, *parsed = strstr(line, "Temperature ");
lastReadTemp = strtof(parsed + 12, &remain);
char *remain, *parsed = NULL;
if (fgets(line, 20, file))
parsed = strstr(line, "Temperature ");
if (parsed)
lastReadTemp = strtof(parsed + 12, &remain);
Comment on lines +349 to +350

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Status shows stale temperatures 🐞 Bug ≡ Correctness

hal_temperature_read() leaves lastReadTemp unchanged when the new parsed guard rejects a line,
even though it has already advanced lastMillisTemp. If TEMP_R stops containing Temperature 
after a successful reading, /api/status and the temperature overlay keep displaying the old value
until a valid reading returns.
Agent Prompt
## Issue description
A missing temperature marker leaves the previous reading cached and visible as current.

## Fix Focus Areas
- src/hal/support.c[332-352]
- src/server.c[1559-1570]
- src/region.c[86-94]

## Recommended Fix
On an unsuccessful temperature read or parse, invalidate the cached value rather than retaining the previous reading. Have status and overlay formatting display an unavailable value when no valid temperature exists; only mark a reading fresh after a successful parse.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

fclose(file);
}
break;
Expand Down