From a7adc0af074826a4c68c7395d2abfd4b931955df Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Wed, 7 Dec 2022 20:04:15 -0600 Subject: Make the cycle limit optional --- tb/top/conspiracion.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tb/top') diff --git a/tb/top/conspiracion.cpp b/tb/top/conspiracion.cpp index bd1086a..f222e54 100644 --- a/tb/top/conspiracion.cpp +++ b/tb/top/conspiracion.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -204,7 +205,7 @@ int main(int argc, char **argv) args::ValueFlag cycles ( - parser, "cycles", "Number of core cycles to run", {"cycles"}, 256 + parser, "cycles", "Max number of core cycles to run", {"cycles"}, UINT_MAX ); args::ValueFlag control_fd @@ -446,9 +447,10 @@ int main(int argc, char **argv) }; unsigned i = 0; - while(!failed && i < *cycles) + // Abuse unsigned overflow (cycles is UINT_MAX by default) + while(!failed && i + 1 <= *cycles) { - for(; i < *cycles; ++i) + for(; i + 1 <= *cycles; ++i) { cycle(); if(failed || top.cpu_halted) [[unlikely]] -- cgit v1.2.3