From 6e68744d76c93b6e2cdf426eb7b24ae5af776e90 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Fri, 16 Sep 2022 12:38:19 +0200 Subject: [PATCH] sys/shell: port random shell command to ztimer This fixed compilation, as the use of the interal `_xtimer_now()` function is not compatible with `ztimer_xtimer_compat`. However, this bug never triggered due to a bug in the build system preventing the compilation of the shell command. We are about to fix this, so let's fix the source first. --- sys/shell/commands/sc_random.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sys/shell/commands/sc_random.c b/sys/shell/commands/sc_random.c index 0afcbe6d73..9944a500f7 100644 --- a/sys/shell/commands/sc_random.c +++ b/sys/shell/commands/sc_random.c @@ -27,24 +27,22 @@ #include "random.h" #include "shell.h" -#ifdef MODULE_XTIMER -#include "xtimer.h" -#endif +#include "ztimer.h" static int _random_init(int argc, char **argv) { int initval; if (argc == 1) { -#ifdef MODULE_XTIMER - initval = _xtimer_now(); - printf("PRNG initialized to current time: %d\n", initval); -#else - (void)initval; - puts("xtimer module not compiled in, can't initialize by time.\n" - "Please provide a seed.\n"); - return 1; -#endif + if (IS_USED(MODULE_ZTIMER_USEC)) { + initval = ztimer_now(ZTIMER_USEC); + printf("PRNG initialized to current time: %d\n", initval); + } + else { + puts("xtimer module not compiled in, can't initialize by time.\n" + "Please provide a seed.\n"); + return 1; + } } else { initval = atoi(argv[1]);