From a5ab87c9c24f176a474dc1b7d3cb4cc4fe4d8ed4 Mon Sep 17 00:00:00 2001 From: Derek Bruening Date: Mon, 2 Nov 2020 17:43:33 -0500 Subject: [PATCH] i#4511,i#4363: Fix gcc 10 build warnings (#4514) Fixes a gcc 10 build warning on snprintf overlapping in drdeploy.c by disabling the warning type. A better solution would be nice to avoid missing warnings on real problems but this will do for now. Fixes a warning about ignoring a return value in the client.alloc test. Fixes #4363 Fixes #4511 --- suite/tests/client-interface/alloc.dll.c | 3 ++- tools/CMakeLists.txt | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/suite/tests/client-interface/alloc.dll.c b/suite/tests/client-interface/alloc.dll.c index 271b119abd2..66bb914b711 100644 --- a/suite/tests/client-interface/alloc.dll.c +++ b/suite/tests/client-interface/alloc.dll.c @@ -631,7 +631,8 @@ inline_alloc_test(void) #if defined(LINUX) && defined(X86_64) /* i#4335: Test allocation of more than 2.8GB in unreachable heap */ for (int i = 0; i != 50; ++i) { - malloc(100000000); + if (malloc(100000000) == NULL) + dr_fprintf(STDERR, "Failed to allocate\n"); } #endif } diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 19a8280449c..4a935f41ee5 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,5 +1,5 @@ # ********************************************************** -# Copyright (c) 2010-2019 Google, Inc. All rights reserved. +# Copyright (c) 2010-2020 Google, Inc. All rights reserved. # Copyright (c) 2009-2010 VMware, Inc. All rights reserved. # ********************************************************** @@ -160,7 +160,13 @@ else (UNIX) endif (UNIX) -# we generate 3 different tools from drdeploy.c +# We generate 3 different tools from drdeploy.c. +if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_COMPILER_IS_CLANG) + # Work around a false positive snprintf warning from gcc: i#4363. + # XXX i#4363: A better solution would be nice to avoid missing + # warnings on real snprintf issues. + set_source_files_properties(drdeploy.c PROPERTIES COMPILE_FLAGS "-Wno-restrict") +endif () add_executable(drconfig drdeploy.c ${RESOURCES}) set_target_properties(drconfig PROPERTIES COMPILE_FLAGS "${tool_cflags} -DRC_IS_drconfig -DDRCONFIG")