This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Fix msp430 build with gcc-5
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 4 Feb 2015 23:17:51 -0000
- Subject: [binutils-gdb] Fix msp430 build with gcc-5
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=64a81db054a44e5539c4de5103125f3587de6403
commit 64a81db054a44e5539c4de5103125f3587de6403
Author: Alan Modra <amodra@gmail.com>
Date: Thu Feb 5 09:14:56 2015 +1030
Fix msp430 build with gcc-5
gcc-5 correctly complains "loop exit may only be reached after
undefined behavior". I was going to correct this by checking the
index before dereferencing the array rather than the other way around,
but then I noticed it is possible for extract_cmd to write the
terminating zero one past the end of "cmd". Fixing that means no
index check is needed in md_assemble.
* config/tc-msp430.c (md_assemble): Correct size passed to
extract_cmd. Remove index check.
Diff:
---
gas/ChangeLog | 5 +++++
gas/config/tc-msp430.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index f216b84..f354c22 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-05 Alan Modra <amodra@gmail.com>
+
+ * config/tc-msp430.c (md_assemble): Correct size passed to
+ extract_cmd. Remove index check.
+
2015-02-04 Matthew Wahab <matthew.wahab@arm.com>
* config/tc-aarch64.c (aarch64_cpus): Add support for Cortex-A72.
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index e44e7b2..2891c13 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -3174,9 +3174,9 @@ md_assemble (char * str)
unsigned int i = 0;
str = skip_space (str); /* Skip leading spaces. */
- str = extract_cmd (str, cmd, sizeof (cmd));
+ str = extract_cmd (str, cmd, sizeof (cmd) - 1);
- while (cmd[i] && i < sizeof (cmd))
+ while (cmd[i])
{
char a = TOLOWER (cmd[i]);
cmd[i] = a;