Merge "Avoid zero-initializing our most-used buffers."
Cr-Mirrored-From: https://chromium.googlesource.com/aosp/platform/system/core
Cr-Mirrored-Commit: 7cae3345d3654a23a607b7da4dfa1fa630962cb4
diff --git a/file.cpp b/file.cpp
index 6321fc6..97cc2b2 100644
--- a/file.cpp
+++ b/file.cpp
@@ -225,7 +225,7 @@
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);
diff --git a/logging.cpp b/logging.cpp
index 6e9c67f..5bd21da 100644
--- a/logging.cpp
+++ b/logging.cpp
@@ -260,7 +260,7 @@
// 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",
diff --git a/stringprintf.cpp b/stringprintf.cpp
index 78e1e8d..e83ab13 100644
--- a/stringprintf.cpp
+++ b/stringprintf.cpp
@@ -25,7 +25,7 @@
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