From a34e99eee64262265541c3cc11075a5a29612ead Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sat, 4 Jan 2020 20:07:11 +0000 Subject: [PATCH] ssp: knock out some trivial warnings that come up with WARNS=6 A future commit will rebuild this as part of libssp. The exact warnings are fairly trivially fixed: - No previous declaration for __stack_chk_guard - idx is the wrong type, nitems yields a size_t - Casting away volatile on the tmp_stack_chk_guard directly is a no-no. Reviewed by: kib, emaste, pfg, Oliver Pinter (earlier version) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22943 --- lib/libc/secure/stack_protector.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/libc/secure/stack_protector.c b/lib/libc/secure/stack_protector.c index 63c02cd96033..15460278502d 100644 --- a/lib/libc/secure/stack_protector.c +++ b/lib/libc/secure/stack_protector.c @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); __attribute__((__constructor__, __used__)); #endif +extern long __stack_chk_guard[8]; extern int __sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); @@ -73,8 +74,8 @@ __guard_setup(void) { static const int mib[2] = { CTL_KERN, KERN_ARND }; volatile long tmp_stack_chk_guard[nitems(__stack_chk_guard)]; - size_t len; - int error, idx; + size_t idx, len; + int error; if (__stack_chk_guard[0] != 0) return; @@ -84,7 +85,8 @@ __guard_setup(void) * data into a temporal array, then do manual volatile copy to * not allow optimizer to call memcpy() behind us. */ - error = _elf_aux_info(AT_CANARY, (void *)tmp_stack_chk_guard, + error = _elf_aux_info(AT_CANARY, + __DEQUALIFY(void *, tmp_stack_chk_guard), sizeof(tmp_stack_chk_guard)); if (error == 0 && tmp_stack_chk_guard[0] != 0) { for (idx = 0; idx < nitems(__stack_chk_guard); idx++) {