From bf7f70ffb57c900d18fed28ad05fc2876d435b3d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 2 Dec 2016 22:39:43 +0000 Subject: [PATCH] selftest.c: remove calls to strndup (PR bootstrap/78616) gcc/ChangeLog: PR bootstrap/78616 * selftest.c (selftest::assert_strndup_eq): Rename to... (selftest::assert_xstrndup_eq): ...this, and remove call to strndup. (selftest::test_strndup): Rename to... (selftest::test_xstrndup): ...this, updating for above renaming. (selftest::test_libiberty): Update for renaming. From-SVN: r243207 --- gcc/ChangeLog | 10 ++++++++++ gcc/selftest.c | 40 +++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 19394b08bc3..18efa0405af 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2016-12-02 David Malcolm + + PR bootstrap/78616 + * selftest.c (selftest::assert_strndup_eq): Rename to... + (selftest::assert_xstrndup_eq): ...this, and remove call to + strndup. + (selftest::test_strndup): Rename to... + (selftest::test_xstrndup): ...this, updating for above renaming. + (selftest::test_libiberty): Update for renaming. + 2016-12-02 Michael Meissner PR target/78639 diff --git a/gcc/selftest.c b/gcc/selftest.c index 6df73c24084..40c6cb54b50 100644 --- a/gcc/selftest.c +++ b/gcc/selftest.c @@ -200,41 +200,35 @@ read_file (const location &loc, const char *path) /* Selftests for libiberty. */ -/* Verify that both strndup and xstrndup generate EXPECTED - when called on SRC and N. */ +/* Verify that xstrndup generates EXPECTED when called on SRC and N. */ static void -assert_strndup_eq (const char *expected, const char *src, size_t n) +assert_xstrndup_eq (const char *expected, const char *src, size_t n) { - char *buf = strndup (src, n); - if (buf) - ASSERT_STREQ (expected, buf); - free (buf); - - buf = xstrndup (src, n); + char *buf = xstrndup (src, n); ASSERT_STREQ (expected, buf); free (buf); } -/* Verify that strndup and xstrndup work as expected. */ +/* Verify that xstrndup works as expected. */ static void -test_strndup () +test_xstrndup () { - assert_strndup_eq ("", "test", 0); - assert_strndup_eq ("t", "test", 1); - assert_strndup_eq ("te", "test", 2); - assert_strndup_eq ("tes", "test", 3); - assert_strndup_eq ("test", "test", 4); - assert_strndup_eq ("test", "test", 5); + assert_xstrndup_eq ("", "test", 0); + assert_xstrndup_eq ("t", "test", 1); + assert_xstrndup_eq ("te", "test", 2); + assert_xstrndup_eq ("tes", "test", 3); + assert_xstrndup_eq ("test", "test", 4); + assert_xstrndup_eq ("test", "test", 5); /* Test on an string without zero termination. */ const char src[4] = {'t', 'e', 's', 't'}; - assert_strndup_eq ("", src, 0); - assert_strndup_eq ("t", src, 1); - assert_strndup_eq ("te", src, 2); - assert_strndup_eq ("tes", src, 3); - assert_strndup_eq ("test", src, 4); + assert_xstrndup_eq ("", src, 0); + assert_xstrndup_eq ("t", src, 1); + assert_xstrndup_eq ("te", src, 2); + assert_xstrndup_eq ("tes", src, 3); + assert_xstrndup_eq ("test", src, 4); } /* Run selftests for libiberty. */ @@ -242,7 +236,7 @@ test_strndup () static void test_libiberty () { - test_strndup (); + test_xstrndup (); } /* Selftests for the selftest system itself. */ -- 2.30.2