Use vsnprintf(3) in syslog(3).

It seemed like a clever trick to use the internal log message formatting
code in syslog(3), but on reflection that means you can't (for example)
format floating point numbers. This patch switches us over to using good
old vsnprintf(3), even though that requires us to jump through a few hoops.

There's no obvious way to unit test this, so I wrote a little program and
ran that.

(cherry-pick of b1b60c30bf321c0fc02264b953b5c16c49d34457.)

Bug: 14292866
Change-Id: I9c83500ba9cbb209b6f496067a91bf69434eeef5
This commit is contained in:
Elliott Hughes
2014-07-25 20:31:47 -07:00
parent 1a918d9be8
commit f1e83cc34a
3 changed files with 47 additions and 16 deletions

View File

@@ -176,14 +176,3 @@ TEST(libc_logging, lld_LLONG_MIN) {
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif // __BIONIC__
}
TEST(libc_logging, m) {
#if defined(__BIONIC__)
char buf[BUFSIZ];
errno = EBADF;
__libc_format_buffer(buf, sizeof(buf), "<%m>");
EXPECT_STREQ("<Bad file number>", buf);
#else // __BIONIC__
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif // __BIONIC__
}