From patchwork Thu Jan 31 17:24:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 31259 Received: (qmail 50335 invoked by alias); 31 Jan 2019 17:24:57 -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 50322 invoked by uid 89); 31 Jan 2019 17:24:57 -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, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR02-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr10070.outbound.protection.outlook.com (HELO EUR02-HE1-obe.outbound.protection.outlook.com) (40.107.1.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Jan 2019 17:24:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gxDZPTogAIGTtiQB7Oxq4guw8XCcB3ZteEj5+2/ihnU=; b=Zfxv0W2mPii4LqzrqejaHaSNVpWSvxDLmZhfiGNqDn9FL+9xWWdTHW77D2BvQ6H7odvPZ7Z+THjDSK9mEhajAascoIJGOqhnKx9ehLuozK7g9HhqM2hdbOkyfVYxPnSVc45Kb2pQoAyXg/20fv/pVtkIdqZ1WazyS0ZJSZe19Ho= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2405.eurprd08.prod.outlook.com (10.172.250.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1580.17; Thu, 31 Jan 2019 17:24:51 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::acd7:a958:2aaa:562e]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::acd7:a958:2aaa:562e%5]) with mapi id 15.20.1580.017; Thu, 31 Jan 2019 17:24:51 +0000 From: Alan Hayward To: Joel Brobecker CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH] Readline: Cleanup some warnings Date: Thu, 31 Jan 2019 17:24:51 +0000 Message-ID: <3463805B-A8BF-4C20-ACE3-C21AE3F7DB62@arm.com> References: <20190130085716.75179-1-alan.hayward@arm.com> <20190131075907.GA313@adacore.com> In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 Content-ID: <68F287970080BF44A9E497AF59345C85@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-IsSubscribed: yes > On 31 Jan 2019, at 10:02, Alan Hayward wrote: > > > >> On 31 Jan 2019, at 07:59, Joel Brobecker wrote: >> >>> (Posted this first to binutils, then was directed back here and >>> pointed at the upstream readline. Looking at the upstream >>> readline it has already fixed the issues below in the same way. >>> Tested by running the gdb testsuite - couldn't see a readline >>> specific suite.) >>> >>> Cleanup the readline warnings that gdb buildbot complains about. >>> >>> To prevent wcwidth missing declaration warnings, add the SOURCE / >>> EXTENSION macros to config.in that have already checked for in >>> configure. Use the exact same list as GDB - it seemed sensible >>> to add all of them. >>> >>> Ensure pid is a long before printing as one. Also fix GNU style. >>> >>> Check the return value of write the same way as history_do_write (). >>> >>> These changes are consistent with upstream readline. >>> >>> readline/ChangeLog.gdb: >>> >>> 2019-01-30 Alan Hayward >>> >>> * config.h.in: Add SOURCE/EXTENSION macros. >>> * histfile.c (history_truncate_file): Check return of write. >>> * util.c: Ensure pid is long. >> >> If it is a backport > > Technically, not a back port because I wrote the changes then realised > they are the same as upstream. Just a quick thought - would it help > with future rebasing if I ensured the changes were *exactly* the same? > (For example, the config.h.in changes are in a different place in the > file with different comments). > >> from mainline readline, and you've run >> the testsuite (readline is being necessarily extensively covered, >> but at least it is used implicitly, since it provides the framework >> for the interactive prompt, which is being driven via expect/tcl), >> it's OK to push. Thinking about what you said, I’ve updated the config.h.in code so it is a direct backport, and pushed. Functionally it’s the same as the original version. Patch pasted below. diff --git a/readline/config.h.in b/readline/config.h.in index 86d86cfa3d..c194e761a4 100644 --- a/readline/config.h.in +++ b/readline/config.h.in @@ -1,5 +1,15 @@ /* config.h.in. Maintained by hand. */ +/* Template definitions for autoconf */ +#undef __EXTENSIONS__ +#undef _ALL_SOURCE +#undef _GNU_SOURCE +#undef _POSIX_SOURCE +#undef _POSIX_1_SOURCE +#undef _POSIX_PTHREAD_SEMANTICS +#undef _TANDEM_SOURCE +#undef _MINIX + /* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte characters, even if the OS supports them. */ #undef NO_MULTIBYTE_SUPPORT diff --git a/readline/histfile.c b/readline/histfile.c index fffeb3fd31..56cbbf0498 100644 --- a/readline/histfile.c +++ b/readline/histfile.c @@ -407,7 +407,8 @@ history_truncate_file (fname, lines) truncate to. */ if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1)) { - write (file, bp, chars_read - (bp - buffer)); + if (write (file, bp, chars_read - (bp - buffer)) < 0) + rv = errno; #if defined (__BEOS__) /* BeOS ignores O_TRUNC. */ diff --git a/readline/util.c b/readline/util.c index d402fce842..13bd00c09c 100644 --- a/readline/util.c +++ b/readline/util.c @@ -515,11 +515,11 @@ _rl_tropen () (sh_get_env_value ("TEMP") ? sh_get_env_value ("TEMP") : "."), - getpid()); + getpid ()); #else - sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid()); + sprintf (fnbuf, "/var/tmp/rltrace.%ld", (long) getpid ()); #endif - unlink(fnbuf); + unlink (fnbuf); _rl_tracefp = fopen (fnbuf, "w+"); return _rl_tracefp != 0; }