diff options
-rw-r--r-- | migration/migration-hmp-cmds.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index cef5608..bb95488 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -57,11 +57,9 @@ static const gchar *format_time_str(uint64_t us) const char *units[] = {"us", "ms", "sec"}; int index = 0; - while (us > 1000) { + while (us > 1000 && index + 1 < ARRAY_SIZE(units)) { us /= 1000; - if (++index >= (sizeof(units) - 1)) { - break; - } + index++; } return g_strdup_printf("%"PRIu64" %s", us, units[index]); |