public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] libasm: Fix GCC7 one -Wformat-truncation=2 warning.
Date: Sun, 12 Feb 2017 20:54:00 -0000	[thread overview]
Message-ID: <1486932876-28211-1-git-send-email-mark@klomp.org> (raw)

Make sure that if we have really many labels the tempsym doesn't get
truncated because it is too small to hold the whole name.

This doesn't enable -Wformat-truncation=2 or fix other "issues" pointed
out by enabling this warning because there are currently some issues
with it. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79448

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libasm/ChangeLog    | 6 +++++-
 libasm/asm_newsym.c | 6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index fe06007..3f842f0 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,4 +1,8 @@
-2015-10-11  Akihiko Odaki  <akihiko.odaki.4i@stu.hosei.ac.jp>
+2017-02-12  Mark Wielaard  <mjw@redhat.com>
+
+	* asm_newsym.c (asm_newsym): Increase TEMPSYMLEN to 13.
+
+2016-10-11  Akihiko Odaki  <akihiko.odaki.4i@stu.hosei.ac.jp>
 
 	* asm_align.c: Remove sys/param.h include.
 
diff --git a/libasm/asm_newsym.c b/libasm/asm_newsym.c
index 332432a..5389166 100644
--- a/libasm/asm_newsym.c
+++ b/libasm/asm_newsym.c
@@ -1,5 +1,5 @@
 /* Define new symbol for current position in given section.
-   Copyright (C) 2002, 2005, 2016 Red Hat, Inc.
+   Copyright (C) 2002, 2005, 2016, 2017 Red Hat, Inc.
    This file is part of elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -44,7 +44,9 @@ AsmSym_t *
 asm_newsym (AsmScn_t *asmscn, const char *name, GElf_Xword size,
 	    int type, int binding)
 {
-#define TEMPSYMLEN 10
+/* We don't really expect labels with many digits, but in theory it could
+   be 10 digits (plus ".L" and a zero terminator).  */
+#define TEMPSYMLEN 13
   char tempsym[TEMPSYMLEN];
   AsmSym_t *result;
 
-- 
1.8.3.1

             reply	other threads:[~2017-02-12 20:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-12 20:54 Mark Wielaard [this message]
2017-03-24 16:49 ` Mark Wielaard

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=1486932876-28211-1-git-send-email-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.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).