Merge pull request #11 from Wenz-jam/master

fix: uint32_t overflow in format_time
This commit is contained in:
Zihao Yu 2024-01-16 16:58:45 +08:00 committed by GitHub
commit 9e19ebc991
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);