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: [COMMITTED] backends: ppc use define instead of const for size of dwarf_regs array.
Date: Sat, 20 Oct 2018 11:24:00 -0000	[thread overview]
Message-ID: <1540034679-19421-1-git-send-email-mark@klomp.org> (raw)

The size of the dwarf_regs is a constant, but when building without
optimizations the compiler doesn't see that and will warn that it
cannot proof the stack size is bounded. Use a define instead of a
const, so the compiler will use a constant expression everywhere.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 backends/ChangeLog     | 5 +++++
 backends/ppc_initreg.c | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index a7434dd..768c270 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,8 @@
+2018-10-20  Mark Wielaard  <mark@klomp.org>
+
+	* ppc_initreg.c (ppc_set_initial_registers_tid): Use define instead of
+	const for size of dwarf_regs array.
+
 2018-10-02  Andreas Schwab  <schwab@suse.de>
 
 	* riscv_symbol.c (riscv_reloc_simple_type): Add parameter addsub.
diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c
index 3e4432f..0e0d359 100644
--- a/backends/ppc_initreg.c
+++ b/backends/ppc_initreg.c
@@ -93,11 +93,11 @@ ppc_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
       if (errno != 0)
 	return false;
     }
-  const size_t gprs = sizeof (user_regs.r.gpr) / sizeof (*user_regs.r.gpr);
-  Dwarf_Word dwarf_regs[gprs];
-  for (unsigned gpr = 0; gpr < gprs; gpr++)
+#define GPRS (sizeof (user_regs.r.gpr) / sizeof (*user_regs.r.gpr))
+  Dwarf_Word dwarf_regs[GPRS];
+  for (unsigned gpr = 0; gpr < GPRS; gpr++)
     dwarf_regs[gpr] = user_regs.r.gpr[gpr];
-  if (! setfunc (0, gprs, dwarf_regs, arg))
+  if (! setfunc (0, GPRS, dwarf_regs, arg))
     return false;
   dwarf_regs[0] = user_regs.r.link;
   // LR uses both 65 and 108 numbers, there is no consistency for it.
-- 
1.8.3.1

                 reply	other threads:[~2018-10-20 11:24 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=1540034679-19421-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).