Skip to content

Commit 9a72f1c

Browse files
Explorer09BenBE
authored andcommitted
Row_printNanoseconds() code portability improvements
Add explicit casts to fix the "-Wshorten-64-to-32" warning (enabled by default in Clang 19). Also shorten the type width for some local variables (where "uint32_t" is enough and no need for "unsigned long"). Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 59578af commit 9a72f1c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Row.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,23 +428,23 @@ void Row_printNanoseconds(RichString* str, unsigned long long totalNanoseconds,
428428
}
429429

430430
unsigned long long totalSeconds = totalMicroseconds / 1000000;
431-
unsigned long microseconds = totalMicroseconds % 1000000;
431+
uint32_t microseconds = totalMicroseconds % 1000000;
432432
if (totalSeconds < 60) {
433433
int width = 5;
434-
unsigned long fraction = microseconds / 10;
434+
uint32_t fraction = microseconds / 10;
435435
if (totalSeconds >= 10) {
436436
width--;
437437
fraction /= 10;
438438
}
439-
len = xSnprintf(buffer, sizeof(buffer), "%u.%0*lus ", (unsigned int)totalSeconds, width, fraction);
439+
len = xSnprintf(buffer, sizeof(buffer), "%u.%0*lus ", (unsigned int)totalSeconds, width, (unsigned long)fraction);
440440
RichString_appendnAscii(str, baseColor, buffer, len);
441441
return;
442442
}
443443

444444
if (totalSeconds < 600) {
445-
unsigned int minutes = totalSeconds / 60;
446-
unsigned int seconds = totalSeconds % 60;
447-
unsigned int milliseconds = microseconds / 1000;
445+
unsigned int minutes = (unsigned int)totalSeconds / 60;
446+
unsigned int seconds = (unsigned int)totalSeconds % 60;
447+
unsigned int milliseconds = (unsigned int)(microseconds / 1000);
448448
len = xSnprintf(buffer, sizeof(buffer), "%u:%02u.%03u ", minutes, seconds, milliseconds);
449449
RichString_appendnAscii(str, baseColor, buffer, len);
450450
return;

0 commit comments

Comments
 (0)