From 424dd8e7b52828cad44ce653a5d4ac30670f5e2c Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 13 Aug 2020 16:37:32 +0200 Subject: executor: warn about C89-style var declarations We generally use the newer C99 var declarations combined with initialization because: - declarations are more local, reduced scope - fewer lines of code - less potential for using uninit vars and other bugs However, we have some relic code from times when we did not understand if we need to stick with C89 or not. Also some external contributions that don't follow style around. Add a static check for C89-style declarations and fix existing precedents. Akaros toolchain uses -std=gnu89 (or something) and does not allow variable declarations inside of for init statement. And we can't switch it to -std=c99 because Akaros headers are C89 themselves. So in common.h we need to declare loop counters outside of for. --- executor/common_fuchsia.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'executor/common_fuchsia.h') diff --git a/executor/common_fuchsia.h b/executor/common_fuchsia.h index f8fa8ffec..2d76891da 100644 --- a/executor/common_fuchsia.h +++ b/executor/common_fuchsia.h @@ -245,8 +245,7 @@ static long syz_job_default(void) #if SYZ_EXECUTOR || __NR_syz_future_time static long syz_future_time(volatile long when) { - zx_time_t delta_ms; - zx_time_t now; + zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; @@ -254,10 +253,8 @@ static long syz_future_time(volatile long when) case 1: delta_ms = 30; break; - default: - delta_ms = 10000; - break; } + zx_time_t now = 0; zx_clock_get(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } -- cgit mrf-deployment