public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Qian Jianhua <qianjh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-7748] print-tree:Avoid warnings of overflow
Date: Tue, 22 Mar 2022 05:41:14 +0000 (GMT)	[thread overview]
Message-ID: <20220322054114.C16A53857823@sourceware.org> (raw)

https://gcc.gnu.org/g:c6bc4835659d24edc2bf5de13bfe8f59ae409ff3

commit r12-7748-gc6bc4835659d24edc2bf5de13bfe8f59ae409ff3
Author: Qian Jianhua <qianjh@cn.fujitsu.com>
Date:   Tue Mar 22 08:44:51 2022 +0800

    print-tree:Avoid warnings of overflow
    
    This patch avoids two warnings of "'sprintf' may write a
    terminating nul past the end of the destination
    [-Wformat-overflow=]" when build GCC.
    
    Tested on x86_64, and committed as obvious.
    
    gcc/ChangeLog:
    
            * print-tree.cc: Change array length

Diff:
---
 gcc/print-tree.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc
index 0876da873a9..6d45a4a5966 100644
--- a/gcc/print-tree.cc
+++ b/gcc/print-tree.cc
@@ -776,7 +776,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
 	    {
 	      /* Buffer big enough to format a 32-bit UINT_MAX into, plus
 		 the text.  */
-	      char temp[15];
+	      char temp[16];
 
 	      sprintf (temp, "arg:%d", i);
 	      print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
@@ -886,7 +886,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
 	      {
 	      /* Buffer big enough to format a 32-bit UINT_MAX into, plus
 		 the text.  */
-		char temp[15];
+		char temp[16];
 		sprintf (temp, "elt:%d", i);
 		print_node (file, temp, TREE_VEC_ELT (node, i), indent + 4);
 	      }


                 reply	other threads:[~2022-03-22  5:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220322054114.C16A53857823@sourceware.org \
    --to=qianjh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).