[PATCH v2] CSKY: Fix sprintf argument overlaping destination error.
Cooper Qu
cooper.qu@linux.alibaba.com
Wed Sep 9 15:41:40 GMT 2020
Fix compilation failure when building with gcc-10:
csky-dis.c:678:2: error: ‘sprintf’ argument 3 overlaps destination object ‘str’
csky-dis.c:650:2: error: ‘sprintf’ argument 3 overlaps destination object ‘str’
opcodes/
* csky-dis.c (csky_output_operand): Fix sprintf argument
overlaping destination error.
---
opcodes/ChangeLog | 5 +++++
opcodes/csky-dis.c | 6 ++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index bd5a284949d..50dcf68a2ac 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2020-09-09 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * csky-dis.c (csky_output_operand): Fix sprintf argument
+ overlaping destination error.
+
2020-09-07 Cooper Qu <cooper.qu@linux.alibaba.com>
* csky-opc.h (csky_v2_opcodes): Change mvtc and mulsw's
diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index 89f1c6bcb3d..f18c53bbeb5 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -647,7 +647,8 @@ csky_output_operand (char *str, struct operand const *oprnd,
float f = 0;
memcpy (&f, &value, sizeof (float));
- sprintf (str, "%s%f\t// imm9:%4d, imm4:%2d", str, f, imm8, imm4);
+ sprintf (buf, "%f\t// imm9:%4d, imm4:%2d", f, imm8, imm4);
+ strcat (str, buf);
break;
}
@@ -675,7 +676,8 @@ csky_output_operand (char *str, struct operand const *oprnd,
}
double d = 0;
memcpy (&d, &dvalue, sizeof (double));
- sprintf (str, "%s%lf\t// imm9:%4ld, imm4:%2ld", str, d, imm8, imm4);
+ sprintf (buf, "%lf\t// imm9:%4ld, imm4:%2ld", d, imm8, imm4);
+ strcat (str, buf);
break;
}
--
2.26.2
More information about the Binutils
mailing list