From owner-svn-src-stable@freebsd.org Wed Sep 16 23:14:24 2020 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 005C03F4934; Wed, 16 Sep 2020 23:14:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BsGBl69rNz4QbX; Wed, 16 Sep 2020 23:14:23 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B76C720D91; Wed, 16 Sep 2020 23:14:23 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08GNENPG095196; Wed, 16 Sep 2020 23:14:23 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08GNEM1w095192; Wed, 16 Sep 2020 23:14:22 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202009162314.08GNEM1w095192@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Sep 2020 23:14:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r365820 - in stable/12: contrib/libarchive/test_utils contrib/netbsd-tests/lib/libexecinfo contrib/netbsd-tests/lib/librt lib/libc/tests/resolv lib/libc/tests/stdlib/dynthr_mod X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12: contrib/libarchive/test_utils contrib/netbsd-tests/lib/libexecinfo contrib/netbsd-tests/lib/librt lib/libc/tests/resolv lib/libc/tests/stdlib/dynthr_mod X-SVN-Commit-Revision: 365820 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 23:14:24 -0000 Author: kevans Date: Wed Sep 16 23:14:22 2020 New Revision: 365820 URL: https://svnweb.freebsd.org/changeset/base/365820 Log: MFC r365493-r365494, r365600, r365602, r365637: various WARNS fixes r365493: libc/resolv: attempt to fix the test under WARNS=6 In a side-change that I'm working on to start defaulting src builds to WARNS=6 where WARNS isn't otherwise specified, GCC6 (and clang, to a lesser extent) pointed out a number of issues with the resolv tests: - Global method variable that gets shadowed in run_tests() - Signed/unsigned comparison between i in run_tests() and hosts->sl_cur The shadowed variable looks like it might actually be bogus as written, as we pass it to RUN_TESTS -> run_tests, but other parts use the global method instead. This change is mainly geared towards correcting that by removing the global and plumbing the method through from run_tests -> run into the new thread. For the signed/unsigned comparison, there's no compelling reason to not just switch i/nthreads/nhosts to size_t. The review also included a change to the load() function that was better addressed by jhb in r365302. r365494: libc tests: dynthr_mod: fix some WARNS issues This is being addressed as part of a side-patch I'm working on that builds all the things with WARNS=6, instead of relying on it being supplied in just shallow parts of the build with higher-level Makefile.inc. Provide a prototype for mod_main and annotate the thread function argument as unused. r365600: MFV r365599: import fix for a libexecinfo warning at higher WARNS v1.17 of this file included a fix that I just submitted upstream to fix a warning about prevent_inline with external linkage not having been previously declared. r365602: librt: tests: fix minor issues with higher WARNS got_sigalrm is a global with external linkage and must therefore have a previous extern declaration. There's no reason to maintain the status quo there, so just make it static. The result var is unused. This part of the test has not been upstreamed, presumably because it exists solely for sem_clockwait_np. We should perhaps consider moving it into its own test file outside of ^/contrib/netbsd-tests, but this can happen later. r365637: MFV r365636: libarchive: import fix for WARNS=6 builds in testing bits Two more cases of explicitly marking globals for internal linkage where they need not be shared. Committed upstream as of a38e62314a1f. Modified: stable/12/contrib/libarchive/test_utils/test_main.c stable/12/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c stable/12/contrib/netbsd-tests/lib/librt/t_sem.c stable/12/lib/libc/tests/resolv/resolv_test.c stable/12/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/libarchive/test_utils/test_main.c ============================================================================== --- stable/12/contrib/libarchive/test_utils/test_main.c Wed Sep 16 22:55:27 2020 (r365819) +++ stable/12/contrib/libarchive/test_utils/test_main.c Wed Sep 16 23:14:22 2020 (r365820) @@ -475,7 +475,7 @@ static struct line { int count; int skip; } failed_lines[10000]; -const char *failed_filename; +static const char *failed_filename; /* Count this failure, setup up log destination and handle initial report. */ static void __LA_PRINTFLIKE(3, 4) @@ -3458,7 +3458,7 @@ assertion_entry_compare_acls(const char *file, int lin /* Use "list.h" to create a list of all tests (functions and names). */ #undef DEFINE_TEST #define DEFINE_TEST(n) { n, #n, 0 }, -struct test_list_t tests[] = { +static struct test_list_t tests[] = { #include "list.h" }; Modified: stable/12/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c ============================================================================== --- stable/12/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c Wed Sep 16 22:55:27 2020 (r365819) +++ stable/12/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c Wed Sep 16 23:14:22 2020 (r365820) @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.16 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.17 2020/09/09 20:04:10 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.16 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.17 2020/09/09 20:04:10 christos Exp $"); #include #include @@ -47,7 +47,7 @@ void myfunc2(size_t ncalls); void myfunc1(size_t origcalls, volatile size_t ncalls); void myfunc(size_t ncalls); -volatile int prevent_inline; +static volatile int prevent_inline; void myfunc3(size_t ncalls) Modified: stable/12/contrib/netbsd-tests/lib/librt/t_sem.c ============================================================================== --- stable/12/contrib/netbsd-tests/lib/librt/t_sem.c Wed Sep 16 22:55:27 2020 (r365819) +++ stable/12/contrib/netbsd-tests/lib/librt/t_sem.c Wed Sep 16 23:14:22 2020 (r365820) @@ -190,7 +190,7 @@ timespec_add_ms(struct timespec *ts, int ms) } } -volatile sig_atomic_t got_sigalrm = 0; +static volatile sig_atomic_t got_sigalrm = 0; static void sigalrm_handler(int sig __unused) @@ -212,7 +212,6 @@ ATF_TC_BODY(timedwait, tc) { struct timespec ts; sem_t sem; - int result; SEM_REQUIRE(sem_init(&sem, 0, 0)); SEM_REQUIRE(sem_post(&sem)); Modified: stable/12/lib/libc/tests/resolv/resolv_test.c ============================================================================== --- stable/12/lib/libc/tests/resolv/resolv_test.c Wed Sep 16 22:55:27 2020 (r365819) +++ stable/12/lib/libc/tests/resolv/resolv_test.c Wed Sep 16 23:14:22 2020 (r365820) @@ -34,6 +34,8 @@ __RCSID("$NetBSD: resolv.c,v 1.6 2004/05/23 16:59:11 c #include #include +#include +#include #include #include #include @@ -55,14 +57,13 @@ enum method { }; static StringList *hosts = NULL; -static enum method method = METHOD_GETADDRINFO; static int *ask = NULL; static int *got = NULL; static void load(const char *); -static void resolvone(int); +static void resolvone(int, enum method); static void *resolvloop(void *); -static void run(int *); +static void run(int *, enum method); static pthread_mutex_t stats = PTHREAD_MUTEX_INITIALIZER; @@ -172,18 +173,18 @@ resolv_getipnodeby(pthread_t self, char *host) } static void -resolvone(int n) +resolvone(int n, enum method method) { char buf[1024]; pthread_t self = pthread_self(); size_t i = (random() & 0x0fffffff) % hosts->sl_cur; char *host = hosts->sl_str[i]; - struct addrinfo hints, *res; int error, len; len = snprintf(buf, sizeof(buf), "%p: %d resolving %s %d\n", self, n, host, (int)i); (void)write(STDOUT_FILENO, buf, len); + error = 0; switch (method) { case METHOD_GETADDRINFO: error = resolv_getaddrinfo(self, host, i); @@ -195,6 +196,10 @@ resolvone(int n) error = resolv_getipnodeby(self, host); break; default: + /* UNREACHABLE */ + /* XXX Needs an __assert_unreachable() for userland. */ + assert(0 && "Unreachable segment reached"); + abort(); break; } pthread_mutex_lock(&stats); @@ -203,35 +208,53 @@ resolvone(int n) pthread_mutex_unlock(&stats); } +struct resolvloop_args { + int *nhosts; + enum method method; +}; + static void * resolvloop(void *p) { - int *nhosts = (int *)p; - if (*nhosts == 0) + struct resolvloop_args *args = p; + + if (*args->nhosts == 0) { + free(args); return NULL; + } + do - resolvone(*nhosts); - while (--(*nhosts)); + resolvone(*args->nhosts, args->method); + while (--(*args->nhosts)); + free(args); return NULL; } static void -run(int *nhosts) +run(int *nhosts, enum method method) { pthread_t self; int rc; + struct resolvloop_args *args; + /* Created thread is responsible for free(). */ + args = malloc(sizeof(*args)); + ATF_REQUIRE(args != NULL); + + args->nhosts = nhosts; + args->method = method; self = pthread_self(); - rc = pthread_create(&self, NULL, resolvloop, nhosts); + rc = pthread_create(&self, NULL, resolvloop, args); ATF_REQUIRE_MSG(rc == 0, "pthread_create failed: %s", strerror(rc)); } static int run_tests(const char *hostlist_file, enum method method) { - int nthreads = NTHREADS; - int nhosts = NHOSTS; - int i, c, done, *nleft; + size_t nthreads = NTHREADS; + size_t nhosts = NHOSTS; + size_t i; + int c, done, *nleft; hosts = sl_init(); srandom(1234); @@ -251,7 +274,7 @@ run_tests(const char *hostlist_file, enum method metho for (i = 0; i < nthreads; i++) { nleft[i] = nhosts; - run(&nleft[i]); + run(&nleft[i], method); } for (done = 0; !done;) { Modified: stable/12/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c ============================================================================== --- stable/12/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c Wed Sep 16 22:55:27 2020 (r365819) +++ stable/12/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c Wed Sep 16 23:14:22 2020 (r365820) @@ -41,10 +41,12 @@ __FBSDID("$FreeBSD$"); #include #include +void mod_main(int op); + static pthread_t thr; static void * -mod_thread(void *ptr) +mod_thread(void *ptr __unused) { char *volatile dummy;