From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#32189: 27.0.50; GCC 7 warning due to -Wformat-truncation=2 Date: Wed, 18 Jul 2018 18:09:32 +0300 Message-ID: <83601c4m37.fsf@gnu.org> References: <031d18cf-e661-6dea-8882-38d75924d0d4@cornell.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1531926511 857 195.159.176.226 (18 Jul 2018 15:08:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 18 Jul 2018 15:08:31 +0000 (UTC) Cc: 32189@debbugs.gnu.org To: Ken Brown Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 18 17:08:26 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ffo41-00006i-BW for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2018 17:08:25 +0200 Original-Received: from localhost ([::1]:37083 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffo68-00046G-8e for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2018 11:10:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffo5d-0003kV-TO for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 11:10:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffo5a-0001do-2W for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 11:10:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffo5Z-0001dW-US for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 11:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ffo5Z-0007Vn-Ng for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 11:10:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Jul 2018 15:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32189 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32189-submit@debbugs.gnu.org id=B32189.153192658728847 (code B ref 32189); Wed, 18 Jul 2018 15:10:01 +0000 Original-Received: (at 32189) by debbugs.gnu.org; 18 Jul 2018 15:09:47 +0000 Original-Received: from localhost ([127.0.0.1]:47080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffo5L-0007VD-5J for submit@debbugs.gnu.org; Wed, 18 Jul 2018 11:09:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52005) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffo5K-0007Ux-6d for 32189@debbugs.gnu.org; Wed, 18 Jul 2018 11:09:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffo5B-0000tK-Mu for 32189@debbugs.gnu.org; Wed, 18 Jul 2018 11:09:40 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffo5B-0000tC-JJ; Wed, 18 Jul 2018 11:09:37 -0400 Original-Received: from [176.228.60.248] (port=2385 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ffo5A-0007XM-DZ; Wed, 18 Jul 2018 11:09:37 -0400 In-reply-to: <031d18cf-e661-6dea-8882-38d75924d0d4@cornell.edu> (message from Ken Brown on Tue, 17 Jul 2018 15:26:34 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148637 Archived-At: > From: Ken Brown > Date: Tue, 17 Jul 2018 15:26:34 -0400 > > I'm getting the following warning when building the master branch on > Cygwin with GCC 7.3: > > In file included from /usr/include/stdio.h:800:0, > from ../lib/stdio.h:43, > from ../../master/src/w32cygwinx.c:22: > ../../master/src/w32cygwinx.c: In function ‘Fw32_battery_status’: > ../../master/src/w32cygwinx.c:116:26: warning: ‘%3.1f’ directive output > may be truncated writing between 3 and 312 bytes into a region of size > 16 [-Wformat-truncation=] > snprintf (buffer, 16, "%3.1f", h); > ^ > ../../master/src/w32cygwinx.c:116:4: note: ‘__builtin_snprintf’ output > between 4 and 313 bytes into a destination of size 16 > snprintf (buffer, 16, "%3.1f", h); > ^ Do we really need to use -Wformat-truncation? Is it a useful warning switch? The above sounds like useless noise, because the code explicitly _asks_ for truncation. What do people think about this? > The attached patch avoids the warning. Is this a reasonable fix, or is > there a better way? I think if we keep the switch, a better fix is to do this: snprintf (buffer, 16, "%ld", h % 1000000); m = seconds_left / 60; snprintf (buffer, 16, "%ld", m % 20000); etc., you get the point. Thanks.