aboutsummaryrefslogtreecommitdiffstats
path: root/executor/executor_bsd.h
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-08-13 16:37:32 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-08-14 09:40:08 +0200
commit424dd8e7b52828cad44ce653a5d4ac30670f5e2c (patch)
tree55f116b53a92ee8de3f1d5aafbba9566f777e869 /executor/executor_bsd.h
parent54ce1ed6b9fcb3b8d77c43dd4b3533e70cade414 (diff)
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.
Diffstat (limited to 'executor/executor_bsd.h')
-rw-r--r--executor/executor_bsd.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h
index 69c6a132b..ac062d5cc 100644
--- a/executor/executor_bsd.h
+++ b/executor/executor_bsd.h
@@ -117,14 +117,12 @@ static void cover_protect(cover_t* cov)
PROT_READ);
#elif GOOS_openbsd
int mib[2], page_size;
- size_t len;
size_t mmap_alloc_size = kCoverSize * sizeof(uintptr_t);
mib[0] = CTL_HW;
mib[1] = HW_PAGESIZE;
- len = sizeof(page_size);
+ size_t len = sizeof(page_size);
if (sysctl(mib, ARRAY_SIZE(mib), &page_size, &len, NULL, 0) != -1)
- mprotect(cov->data + page_size, mmap_alloc_size - page_size,
- PROT_READ);
+ mprotect(cov->data + page_size, mmap_alloc_size - page_size, PROT_READ);
#endif
}