diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-01-10 10:15:30 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-01-10 10:15:30 +0000 |
commit | 8de1688f47e4cbff1ad2dc3546d807f600a380b1 (patch) | |
tree | ac3e4e3145b708f5dd2fe02cdc17b7c81203636f | |
parent | dd104e1b766241fcb6bdfdc7db9b038cc15669bf (diff) | |
download | mpfr-8de1688f47e4cbff1ad2dc3546d807f600a380b1.tar.gz |
[tests/tsprintf.c] Fixed/simplified code with incorrect strncpy
usage (bug detected by gcc-snapshot 20180107-1 under Debian with
-Werror=stringop-truncation).
(merged changesets r12084-12085 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/4.0@12086 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/tsprintf.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/tests/tsprintf.c b/tests/tsprintf.c index 30038a712..24fed1167 100644 --- a/tests/tsprintf.c +++ b/tests/tsprintf.c @@ -88,14 +88,11 @@ check_sprintf (const char *expected, const char *fmt, mpfr_srcptr x) } if (n0 != n1) { - char format[1024]; printf ("Error in mpfr_snprintf (s, %d, \"%s\", x) return value\n", randsize, fmt); - printf ("expected: %d\ngot: %d\n", n0, n1); - strncpy (format, "x='", 1024); - strncpy (format + 3, fmt, 1021); - strncpy (format + 3 + strlen (fmt), "'\n", 1021 - strlen (fmt)); - mpfr_printf (format, x); + printf ("expected: %d\ngot: %d\nx='", n0, n1); + mpfr_printf (fmt, x); + printf ("'\n"); exit (1); } if ((randsize > 1 && strncmp (expected, buffer, randsize - 1) != 0) |