From 29ecaed9ea7dd5dbde8ac2dc99b31f935be2fea8 Mon Sep 17 00:00:00 2001 From: Daniel Duan Date: Fri, 1 May 2020 17:37:24 -0700 Subject: [PATCH] [tests] Suppress unused return value warnings These cause compile failures due to `-Werror -Wunused-result` when building on NixOS. This PR upstreams patches need to package Swift on that OS. --- tests/bsdtests.c | 14 +++++++------- tests/dispatch_io_muxed.c | 2 +- tests/dispatch_overcommit.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/bsdtests.c b/tests/bsdtests.c index af716626b..6307180fd 100644 --- a/tests/bsdtests.c +++ b/tests/bsdtests.c @@ -347,8 +347,8 @@ _test_errno(const char* file, long line, const char* desc, int actual, int expec { char* actual_str; char* expected_str; - asprintf(&actual_str, "%d\t%s", actual, actual ? strerror(actual) : ""); - asprintf(&expected_str, "%d\t%s", expected, expected ? strerror(expected) : ""); + (void)asprintf(&actual_str, "%d\t%s", actual, actual ? strerror(actual) : ""); + (void)asprintf(&expected_str, "%d\t%s", expected, expected ? strerror(expected) : ""); _test_print(file, line, desc, (actual == expected), "%s", actual_str, "%s", expected_str); free(actual_str); @@ -369,8 +369,8 @@ _test_mach_error(const char* file, long line, const char* desc, { char* actual_str; char* expected_str; - asprintf(&actual_str, "%d %s", actual, actual ? mach_error_string(actual) : ""); - asprintf(&expected_str, "%d %s", expected, expected ? mach_error_string(expected) : ""); + (void)asprintf(&actual_str, "%d %s", actual, actual ? mach_error_string(actual) : ""); + (void)asprintf(&expected_str, "%d %s", expected, expected ? mach_error_string(expected) : ""); _test_print(file, line, desc, (actual == expected), "%s", actual_str, "%s", expected_str); free(actual_str); @@ -416,12 +416,12 @@ test_cferror(const char *desc, CFErrorRef actual, CFIndex expectedCode) if (code != expectedCode) { char buffer[BUFSIZ]; CFStringGetCString(errDesc, buffer, sizeof(buffer), kCFStringEncodingUTF8); - asprintf(&actual_str, "%ld\t%s", code, buffer); + (void)asprintf(&actual_str, "%ld\t%s", code, buffer); } else { - asprintf(&actual_str, "%ld", code); + (void)asprintf(&actual_str, "%ld", code); } - asprintf(&expected_str, "%ld", expectedCode); + (void)asprintf(&expected_str, "%ld", expectedCode); _test_print("", (long) 0, desc, (code == expectedCode), "%s", actual_str, "%s", expected_str); diff --git a/tests/dispatch_io_muxed.c b/tests/dispatch_io_muxed.c index b99b26226..bc7c57cda 100644 --- a/tests/dispatch_io_muxed.c +++ b/tests/dispatch_io_muxed.c @@ -64,7 +64,7 @@ test_file_muxed(void) const char *path_separator = "/"; #endif char *path = NULL; - asprintf(&path, "%s%sdispatchtest_io.XXXXXX", temp_dir, path_separator); + (void)asprintf(&path, "%s%sdispatchtest_io.XXXXXX", temp_dir, path_separator); dispatch_fd_t fd = mkstemp(path); if (fd == -1) { test_errno("mkstemp", errno, 0); diff --git a/tests/dispatch_overcommit.c b/tests/dispatch_overcommit.c index 4c187411d..d2fca3b5c 100644 --- a/tests/dispatch_overcommit.c +++ b/tests/dispatch_overcommit.c @@ -48,7 +48,7 @@ main(void) int i; for (i = 0; i < final; ++i) { char* name; - asprintf(&name, "test.overcommit.%d", i); + (void)asprintf(&name, "test.overcommit.%d", i); dispatch_queue_t queue = dispatch_queue_create(name, NULL); test_ptr_notnull("dispatch_queue_create", queue);