Fix -Wdouble-promotion warnings
This is a manual merge of change
https://android-review.googlesource.com/#/c/328520/ , since automerging
failed.
With the new clang FORTIFY, this code emits the following error:
error: implicit conversion increases floating-point precision: 'float'
to 'double' [-Werror,-Wdouble-promotion]
This is because strncpy is now a function, not a macro defined in a
system header. So, the warning is considered to appear in user code
(instead of system code), and is therefore no longer suppressed.
Bug: 32073964
Test: Now builds with clang FORTIFY
Change-Id: I5e8292d7800434268793bc4db4a96f20b7022e17
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 5ae4faa..07ad4c1 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -64,7 +64,7 @@
const alloc_rec_t& rec(list.valueAt(i));
if (rec.size) {
snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %4u | %8X | 0x%08x | %s\n",
- list.keyAt(i), rec.size/1024.0f,
+ list.keyAt(i), rec.size/1024.0,
rec.width, rec.stride, rec.height, rec.layerCount, rec.format,
rec.usage, rec.requestorName.c_str());
} else {
@@ -76,7 +76,7 @@
result.append(buffer);
total += rec.size;
}
- snprintf(buffer, SIZE, "Total allocated (estimate): %.2f KB\n", total/1024.0f);
+ snprintf(buffer, SIZE, "Total allocated (estimate): %.2f KB\n", total/1024.0);
result.append(buffer);
std::string deviceDump;