mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-07 16:17:38 +03:00
Fix cppcheck warnings in free space probe
- Cast uint64_t to unsigned long long for %llu format specifier (fixes type mismatch on platforms where uint64_t is unsigned long) - Add cppcheck-suppress for useStlAlgorithm on loop with side effects (preAllocate/truncate make std::find_if inappropriate here)
This commit is contained in:
parent
2f90705639
commit
6cebde8a2d
@ -569,7 +569,7 @@ void CalibreWirelessActivity::handleGetDeviceInformation() {
|
||||
void CalibreWirelessActivity::handleFreeSpace() {
|
||||
const uint64_t freeBytes = getSDCardFreeSpace();
|
||||
char response[64];
|
||||
snprintf(response, sizeof(response), "{\"free_space_on_device\":%llu}", freeBytes);
|
||||
snprintf(response, sizeof(response), "{\"free_space_on_device\":%llu}", static_cast<unsigned long long>(freeBytes));
|
||||
sendJsonResponse(OpCode::OK, response);
|
||||
}
|
||||
|
||||
@ -839,11 +839,13 @@ uint64_t CalibreWirelessActivity::getSDCardFreeSpace() const {
|
||||
uint64_t availableSpace = 64ULL * 1024 * 1024; // Minimum 64MB fallback
|
||||
|
||||
for (const uint64_t size : probeSizes) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
if (testFile.preAllocate(size)) {
|
||||
availableSpace = size;
|
||||
// Truncate back to 0 to release the allocation
|
||||
testFile.truncate(0);
|
||||
Serial.printf("[%lu] [CAL] Free space probe: %llu bytes available\n", millis(), availableSpace);
|
||||
Serial.printf("[%lu] [CAL] Free space probe: %llu bytes available\n", millis(),
|
||||
static_cast<unsigned long long>(availableSpace));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user