From: Tulio Magno Quites Machado Filho Date: Mon, 26 Jun 2017 12:55:41 +0000 (-0300) Subject: Prevent an implicit int promotion in malloc/tst-alloc_buffer.c X-Git-Tag: glibc-2.26~237 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d54bb9b1d3fd25779fba2c403003c5097ba9af73;p=thirdparty%2Fglibc.git Prevent an implicit int promotion in malloc/tst-alloc_buffer.c According to ISO C11, section 6.5.3.3 "Unary arithmetic operators", the result of the ~ operator is the bitwise complement of its (promoted) operand. This can lead to a comparison of a char with another integer type. Tested on powerpc, powerpc64 and powerpc64le. * malloc/tst-alloc_buffer.c (test_misaligned): Cast to char before comparing with another char. --- diff --git a/ChangeLog b/ChangeLog index b213e7c4930..9e19f62d9d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-06-26 Tulio Magno Quites Machado Filho + + * malloc/tst-alloc_buffer.c (test_misaligned): Cast to char + before comparing with another char. + 2017-06-25 Rical Jasan * manual/math.texi: Fix a grammatical error. diff --git a/malloc/tst-alloc_buffer.c b/malloc/tst-alloc_buffer.c index 1c143999c70..9b2bd2046a1 100644 --- a/malloc/tst-alloc_buffer.c +++ b/malloc/tst-alloc_buffer.c @@ -429,7 +429,7 @@ test_misaligned (char pad) } /* Verify that padding was not overwritten. */ - TEST_VERIFY (backing[0] == ~pad); + TEST_VERIFY (backing[0] == (char) ~pad); TEST_VERIFY (backing[SIZE + 1] == pad); free (backing); }