From patchwork Fri Aug 10 21:24:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 28845 Received: (qmail 56446 invoked by alias); 10 Aug 2018 21:24:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 56295 invoked by uid 89); 10 Aug 2018 21:24:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=_FORTIFY_SOURCE, _fortify_source X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.148.119) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Aug 2018 21:24:06 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 743C430191 for ; Fri, 10 Aug 2018 16:24:05 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id oEtBfinG7kBj6oEtBf09Ls; Fri, 10 Aug 2018 16:24:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1YUV339ZGgnGB+kwjA9DzCHrHv33QKvAj8DbGO6u7qc=; b=wIGdRyVMjt39VdgedxPZ2VR7JZ lZviy03psl2Z7+KNLsnRqUjYuVqYpim4J/SsSnFeKB2SHY6b08pC7GNvHxpaFsSSo9/k1RTqfH8/G gJztYq8IaBpZ4GEjCFclZHKhm; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:37320 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1foEtB-003xhq-90; Fri, 10 Aug 2018 16:24:05 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Define _FORTIFY_SOURCE in common-defs.h Date: Fri, 10 Aug 2018 15:24:02 -0600 Message-Id: <20180810212402.19814-1-tom@tromey.com> This defines _FORTIFY_SOURCE in common-defs.h. This seems like a sensible safety measure, and also it may help avoid build problems with -Wunused-result on distros that already define _FORTIFY_SOURCE by default. Tested by the buildbot. gdb/ChangeLog 2018-08-10 Tom Tromey * common/common-defs.h (_FORTIFY_SOURCE): Define. --- gdb/ChangeLog | 4 ++++ gdb/common/common-defs.h | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e046b64b5c6..810431f2bfe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2018-08-10 Tom Tromey + + * common/common-defs.h (_FORTIFY_SOURCE): Define. + 2018-08-10 Keith Seitz * compile/compile-c-support.c (add_code_header, add_code_footer): diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h index 80f1ff4f560..58445b16110 100644 --- a/gdb/common/common-defs.h +++ b/gdb/common/common-defs.h @@ -59,6 +59,18 @@ #define __STDC_LIMIT_MACROS 1 #define __STDC_FORMAT_MACROS 1 +/* Some distros enable _FORTIFY_SOURCE by default, which on occasion + has caused build failures with -Wunused-result when a patch is + developed on a distro that does not enable _FORTIFY_SOURCE. We + enable it here in order to try to catch these problems earlier; + plus this seems like a reasonable safety measure. The check for + optimization is required because _FORTIFY_SOURCE only works when + optimization is enabled. */ + +#if defined __OPTIMIZE__ && __OPTIMIZE__ > 0 +#define _FORTIFY_SOURCE 2 +#endif + #include #include #include