From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52694 invoked by alias); 29 Aug 2019 19:54:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 52676 invoked by uid 89); 29 Aug 2019 19:54:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Aug 2019 19:54:29 +0000 Received: by mail-wm1-f65.google.com with SMTP id t9so5018234wmi.5; Thu, 29 Aug 2019 12:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:message-id:date:user-agent:mime-version :content-language; bh=wqScdWV5agG/L/adBZ5XYeyT7fuBrAestySrjQ4MQnM=; b=Qp0xPVhDR2J1uXTWpxtaREGWFISaTNz/D2tyVvQOplHl0SZ0SphSml+1y2DZCJaV2M GtzYF0uj7DRvoia/D+Y+SxXpYO+OaT6484MWt/t+3FxYe6l+pB8imfvXB9lUbNLYzY/e 5MxcdU35wlf+zvckvej4DWB3MB98kRkr0kQSu7QGKSvSzBQJ4evVac17vwxPFyuIXMgB raKhnU7jyA6wixU5sdExF4yKUV1K2ksnvjDrRQTcS5CPFX4N7070zI2Q2TdBFMeB4N7A lDHMhNl8gM4F9tQs1tWP7YYVJwiLoPp4c0ue0hzFTLo06HNuL0C7L2BZRULF8QxOsvdg ZhnQ== Return-Path: Received: from ?IPv6:2a01:e0a:1dc:b1c0:e06f:bc1e:4839:2340? ([2a01:e0a:1dc:b1c0:e06f:bc1e:4839:2340]) by smtp.googlemail.com with ESMTPSA id o11sm2752770wrw.19.2019.08.29.12.54.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 12:54:26 -0700 (PDT) From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Subject: [PATCH] Fix unused malloc return value warning To: "libstdc++@gcc.gnu.org" , gcc-patches Message-ID: Date: Thu, 29 Aug 2019 20:50:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------58C8469BAF037B9BF82BFA8E" X-SW-Source: 2019-08/txt/msg02016.txt.bz2 This is a multi-part message in MIME format. --------------58C8469BAF037B9BF82BFA8E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 760 Hi     I am having this warning: /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/util/testsuite_performance.h:170: attention: ignoring return value of « void* malloc(size_t) » declared with attribute « warn_unused_result » [-Wunused-result]   170 |       malloc(0); // Needed for some implementations.     Ok to fix it with attached patch ?     It seems trivial but I wonder if I shouldn't keep the malloc returned pointer and free it properly ?     Or maybe just remove the malloc cause there is not clear comment explaining why it's needed and I haven't found much in SVN audit trail.     * testsuite_files/util/testsuite_performance.h     (resource_counter::start): Ignore unused malloc(0) result. François --------------58C8469BAF037B9BF82BFA8E Content-Type: text/x-patch; name="testsuite_performance.h.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="testsuite_performance.h.patch" Content-length: 609 diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h index 556c78159be..8abc77cf31a 100644 --- a/libstdc++-v3/testsuite/util/testsuite_performance.h +++ b/libstdc++-v3/testsuite/util/testsuite_performance.h @@ -167,7 +167,7 @@ namespace __gnu_test { if (getrusage(who, &rusage_begin) != 0 ) memset(&rusage_begin, 0, sizeof(rusage_begin)); - malloc(0); // Needed for some implementations. + void* p __attribute__((unused)) = malloc(0); // Needed for some implementations. allocation_begin = mallinfo(); } --------------58C8469BAF037B9BF82BFA8E--