fix uint32_t overflow in format_time

This commit is contained in:
江牛 2024-01-16 16:09:54 +08:00 committed by GitHub
parent 33c0dd0d85
commit 1dc914a675
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@ static uint64_t uptime() { return io_read(AM_TIMER_UPTIME).us; }
static char *format_time(uint64_t us) {
static char buf[32];
uint32_t ms = us / 1000;
uint64_t ms = us / 1000;
us -= ms * 1000;
assert(us < 1000);
int len = sprintf(buf, "%d.000", ms);