From patchwork Mon Jun 10 21:56:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1113352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-102565-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="CqmMggqK"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45N6Qk2L3pz9sBp for ; Tue, 11 Jun 2019 07:56:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=ZF95N+Qt5dF5cUfgkuEm4DZVa7i0G 3tsD4Zjw4XSxtqxIXxak61QO/Dy9GrvVfU/M4xpzHFzvYqlNU21s3uBKcRrShx32 jbD28EOtllDvGJTkCEZ6sUlQTaTTTU3xE1AcvZJIn5LUW72b5LfHvT8U059czCD+ sgdsRt6XX1i92Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=duKcpuWstWJqxpivcSo1Zd2XdC4=; b=Cqm MggqKLhQKAHx8lErXincSFlkJ0q+OnGNIu3YcGFIZx8utMh754NgP3av25wXT9yh 2iqkMGhog9vXqjCq50gzGUKRGkYGdkMiNQl/SD16K8JXyO5i0Ig8BiYPPD+K73HZ vI0sslenC43Vp814bjw1eoV6G3IC21/encCwZEsQ= Received: (qmail 17908 invoked by alias); 10 Jun 2019 21:56:08 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 17830 invoked by uid 89); 10 Jun 2019 21:56:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=duly X-HELO: relay1.mentorg.com Date: Mon, 10 Jun 2019 21:56:00 +0000 From: Joseph Myers To: Subject: Fix malloc tests build with GCC 10 Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 GCC mainline has recently added warn_unused_result attributes to some malloc-like built-in functions, where glibc previously had them in its headers only for __USE_FORTIFY_LEVEL > 0. This results in those attributes being newly in effect for building the glibc testsuite, so resulting in new warnings that break the build where tests deliberately call such functions and ignore the result. Thus patch duly adds calls to DIAG_* macros around those calls to disable the warning. Tested with build-many-glibcs.py for aarch64-linux-gnu. 2019-06-10 Joseph Myers * malloc/tst-calloc.c: Include . (null_test): Ignore -Wunused-result around calls to calloc. * malloc/tst-mallocfork.c: Include . (do_test): Ignore -Wunused-result around call to malloc. diff --git a/malloc/tst-calloc.c b/malloc/tst-calloc.c index 1eac6aecfc..aa3f26d7d7 100644 --- a/malloc/tst-calloc.c +++ b/malloc/tst-calloc.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Number of samples per size. */ @@ -95,12 +96,16 @@ static void null_test (void) { /* If the size is 0 the result is implementation defined. Just make - sure the program doesn't crash. */ + sure the program doesn't crash. The result of calloc is + deliberately ignored, so do not warn about that. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (10, "-Wunused-result"); calloc (0, 0); calloc (0, UINT_MAX); calloc (UINT_MAX, 0); calloc (0, ~((size_t) 0)); calloc (~((size_t) 0), 0); + DIAG_POP_NEEDS_COMMENT; } diff --git a/malloc/tst-mallocfork.c b/malloc/tst-mallocfork.c index 4ff6ec09f4..00851a16c3 100644 --- a/malloc/tst-mallocfork.c +++ b/malloc/tst-mallocfork.c @@ -7,6 +7,7 @@ #include #include #include +#include static void sig_handler (int signum) @@ -25,7 +26,12 @@ do_test (void) struct sigaction action = { .sa_handler = sig_handler }; sigemptyset (&action.sa_mask); + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (10, "-Wunused-result"); + /* The result of malloc is deliberately ignored, so do not warn + about that. */ malloc (sizeof (int)); + DIAG_POP_NEEDS_COMMENT; if (sigaction (SIGALRM, &action, NULL) != 0) {