[compiler-rt] r330458 - [Sanitizer] Internal Printf string precision argument + padding.
Aleksey Shlyapnikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 20 13:27:58 PDT 2018
Yes, it did. Sorry, reverted with r330476.
On Fri, Apr 20, 2018 at 12:48 PM, Peter Collingbourne <peter at pcc.me.uk>
wrote:
> Could this have caused this test failure?
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/11600
>
> Peter
>
> On Fri, Apr 20, 2018 at 11:03 AM, Alex Shlyapnikov via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: alekseyshl
>> Date: Fri Apr 20 11:03:10 2018
>> New Revision: 330458
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=330458&view=rev
>> Log:
>> [Sanitizer] Internal Printf string precision argument + padding.
>>
>> Summary:
>> Example:
>> Printf("%.*s", 5, "123");
>> should yield:
>> '123 '
>>
>> In case Printf's requested string precision is larger than the string
>> argument, the resulting string should be padded up to the requested
>> precision.
>>
>> For the simplicity sake, implementing right padding only.
>>
>> Reviewers: eugenis
>>
>> Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits
>>
>> Differential Revision: https://reviews.llvm.org/D45844
>>
>> Modified:
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
>> compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc
>>
>> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sa
>> nitizer_common/sanitizer_printf.cc?rev=330458&r1=330457&r2=
>> 330458&view=diff
>> ============================================================
>> ==================
>> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc (original)
>> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc Fri Apr
>> 20 11:03:10 2018
>> @@ -105,6 +105,8 @@ static int AppendString(char **buff, con
>> break;
>> result += AppendChar(buff, buff_end, *s);
>> }
>> + while (result < precision)
>> + result += AppendChar(buff, buff_end, ' ');
>> return result;
>> }
>>
>>
>> Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_
>> printf_test.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sa
>> nitizer_common/tests/sanitizer_printf_test.cc?rev=330458&r1=
>> 330457&r2=330458&view=diff
>> ============================================================
>> ==================
>> --- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc
>> (original)
>> +++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc
>> Fri Apr 20 11:03:10 2018
>> @@ -146,8 +146,13 @@ TEST(Printf, Precision) {
>> EXPECT_EQ(3U, len);
>> EXPECT_STREQ("123", buf);
>> len = internal_snprintf(buf, sizeof(buf), "%.*s", 6, "12345");
>> - EXPECT_EQ(5U, len);
>> - EXPECT_STREQ("12345", buf);
>> + EXPECT_EQ(6U, len);
>> + EXPECT_STREQ("12345 ", buf);
>> + // CHeck that precision does not overflow the smaller buffer, although
>> + // 10 chars is requested, it stops at the buffer size, 8.
>> + len = internal_snprintf(buf, 8, "%.*s", 10, "12345");
>> + EXPECT_EQ(10U, len); // The required size reported.
>> + EXPECT_STREQ("12345 ", buf);
>> }
>>
>> } // namespace __sanitizer
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
>
> --
> --
> Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180420/ca90e807/attachment.html>
More information about the llvm-commits
mailing list