Avoid zero-initializing our most-used buffers. am: 08929cc389 am: 9d63c3f8c5 am: 019c7ae0b9

Change-Id: Ic9b865233053b800add8c7e28e8355b1bc2ef1c6
This commit is contained in:
Elliott Hughes 2020-04-30 15:51:45 +00:00 committed by Automerger Merge Worker
commit d90237d76c
3 changed files with 3 additions and 3 deletions

View File

@ -225,7 +225,7 @@ bool ReadFdToString(borrowed_fd fd, std::string* content) {
content->reserve(sb.st_size);
}
char buf[BUFSIZ];
char buf[BUFSIZ] __attribute__((__uninitialized__));
ssize_t n;
while ((n = TEMP_FAILURE_RETRY(read(fd.get(), &buf[0], sizeof(buf)))) > 0) {
content->append(buf, n);

View File

@ -260,7 +260,7 @@ static void KernelLogLine(const char* msg, int length, android::base::LogSeverit
// The kernel's printk buffer is only 1024 bytes.
// TODO: should we automatically break up long lines into multiple lines?
// Or we could log but with something like "..." at the end?
char buf[1024];
char buf[1024] __attribute__((__uninitialized__));
size_t size = snprintf(buf, sizeof(buf), "<%d>%s: %.*s\n", level, tag, length, msg);
if (size > sizeof(buf)) {
size = snprintf(buf, sizeof(buf), "<%d>%s: %zu-byte message too long for printk\n",

View File

@ -25,7 +25,7 @@ namespace base {
void StringAppendV(std::string* dst, const char* format, va_list ap) {
// First try with a small fixed size buffer
char space[1024];
char space[1024] __attribute__((__uninitialized__));
// It's possible for methods that use a va_list to invalidate
// the data in it upon use. The fix is to make a copy