From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Silence two Clang warnings Date: Tue, 13 Jun 2017 13:42:09 -0700 Organization: UCLA Computer Science Department Message-ID: <1e61fe6d-4646-b2ea-9dc1-7b782fc91e05@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------D3994AE0755F53C58DD3CB3C" X-Trace: blaine.gmane.org 1497386628 724 195.159.176.226 (13 Jun 2017 20:43:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Jun 2017 20:43:48 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 Cc: Emacs development discussions To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 13 22:43:45 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKsfA-0008SF-FN for ged-emacs-devel@m.gmane.org; Tue, 13 Jun 2017 22:43:44 +0200 Original-Received: from localhost ([::1]:45164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKsfF-0000zI-Lx for ged-emacs-devel@m.gmane.org; Tue, 13 Jun 2017 16:43:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKsdj-0007oG-Oo for emacs-devel@gnu.org; Tue, 13 Jun 2017 16:42:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKsdg-0000ZT-M7 for emacs-devel@gnu.org; Tue, 13 Jun 2017 16:42:15 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:48912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKsdg-0000ZJ-B9 for emacs-devel@gnu.org; Tue, 13 Jun 2017 16:42:12 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 44A3E1600D2; Tue, 13 Jun 2017 13:42:11 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id imG1-P9chpRo; Tue, 13 Jun 2017 13:42:10 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D288F1600EA; Tue, 13 Jun 2017 13:42:09 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4Hy63qSKDvCn; Tue, 13 Jun 2017 13:42:09 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 763B31600D2; Tue, 13 Jun 2017 13:42:09 -0700 (PDT) Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:215606 Archived-At: This is a multi-part message in MIME format. --------------D3994AE0755F53C58DD3CB3C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Part of the attached patch, recently installed into master, would be automatically reverted the next time we merged from gnulib, since strftime.c is copied from Gnulib. I'm not getting a warning when compiling with Clang, so I'm puzzled as to why the patch was needed. Here's how I build (on Fedora 25): ./configure --enable-gcc-warnings CC=clang Fedora 25 is running clang version 3.9.1 (tags/RELEASE_391/final). Background: I would rather avoid the need for this sort of patch, as we shouldn't have to complicate the code just to pacify a Clang false alarm. If an older Clang is generating a false alarm, let's just ignore the diagnostic. If it's a newer Clang, let's change the options to Clang to suppress the diagnostic. --------------D3994AE0755F53C58DD3CB3C Content-Type: text/x-patch; name="0001-Silence-two-Clang-warnings-by-introducing-additional.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Silence-two-Clang-warnings-by-introducing-additional.pa"; filename*1="tch" >From e408e9aa030a00cb1a61acdc729e8d6786b25fe3 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Tue, 13 Jun 2017 13:55:44 +0200 Subject: [PATCH] Silence two Clang warnings by introducing additional local variables * lib/strftime.c (libc_hidden_def): * lib-src/make-docfile.c (put_filename): Introduce local variables to silence Clang warnings. --- lib-src/make-docfile.c | 6 +++++- lib/strftime.c | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 9470bd6..85bcc8b 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -224,7 +224,11 @@ put_filename (char *filename) for (tmp = filename; *tmp; tmp++) { - if (IS_DIRECTORY_SEP (*tmp)) + /* Use separate variable to silence a Clang warning on macOS. + Clang takes offence of the additional set of parantheses + generated by the macro. */ + bool is_sep = IS_DIRECTORY_SEP (*tmp); + if (is_sep) filename = tmp + 1; } diff --git a/lib/strftime.c b/lib/strftime.c index 99bee4e..18c899d 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -1123,18 +1123,23 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) if (modifier == L_('E')) goto bad_format; - number_value = ns; - if (width == -1) - width = 9; - else - { - /* Take an explicit width less than 9 as a precision. */ - int j; - for (j = width; j < 9; j++) - number_value /= 10; - } + { + /* Use a new variable here instead of reusing number_value + because Clang complains about the self-assignment + generated by DO_NUMBER. */ + ptrdiff_t n = ns; + if (width == -1) + width = 9; + else + { + /* Take an explicit width less than 9 as a precision. */ + int j; + for (j = width; j < 9; j++) + n /= 10; + } - DO_NUMBER (width, number_value); + DO_NUMBER (width, n); + } #endif case L_('n'): -- 2.9.4 --------------D3994AE0755F53C58DD3CB3C--