Merge "Cast from const void * -> const char * when using memchr()."

This commit is contained in:
Treehugger Robot 2020-08-18 15:34:36 +00:00 committed by Gerrit Code Review
commit 3ec750e035
1 changed files with 6 additions and 4 deletions

View File

@ -204,8 +204,9 @@ TEST_F(DEATHTEST, memchr_fortified2) {
foo myfoo;
volatile int asize = sizeof(myfoo.a) + 1;
memcpy(myfoo.a, "0123456789", sizeof(myfoo.a));
ASSERT_FORTIFY(printf("%s", memchr(myfoo.a, 'a', asize)));
ASSERT_FORTIFY(printf("%s", memchr(static_cast<const void*>(myfoo.a), 'a', asize)));
ASSERT_FORTIFY(printf("%s", static_cast<const char*>(memchr(myfoo.a, 'a', asize))));
ASSERT_FORTIFY(printf(
"%s", static_cast<const char*>(memchr(static_cast<const void*>(myfoo.a), 'a', asize))));
#else // __BIONIC__
GTEST_SKIP() << "glibc is broken";
#endif // __BIONIC__
@ -216,8 +217,9 @@ TEST_F(DEATHTEST, memrchr_fortified2) {
foo myfoo;
volatile int asize = sizeof(myfoo.a) + 1;
memcpy(myfoo.a, "0123456789", sizeof(myfoo.a));
ASSERT_FORTIFY(printf("%s", memrchr(myfoo.a, 'a', asize)));
ASSERT_FORTIFY(printf("%s", memrchr(static_cast<const void*>(myfoo.a), 'a', asize)));
ASSERT_FORTIFY(printf("%s", static_cast<const char*>(memrchr(myfoo.a, 'a', asize))));
ASSERT_FORTIFY(printf(
"%s", static_cast<const char*>(memrchr(static_cast<const void*>(myfoo.a), 'a', asize))));
#else // __BIONIC__
GTEST_SKIP() << "glibc is broken";
#endif // __BIONIC__