From 6c7b3cb056509fd8756bc012878a499f6f102114 Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Fri, 11 Oct 2013 16:03:21 -0700 Subject: [PATCH] Fix clang warnings in bionic. This fixes a few diverse issues that clang warns on in bionic. First, it specifies the appropriate converted types for format specifiers. The "h" and "hh" modifiers specify that the user is passing a short or char respectively. We were passing int deliberately in both cases and relying on the compiler to implicitly downcast to the smaller type. We also remove the non-standard "d" suffix from our double-precision floating point constant. This is an extension for gcc that clang does not implement. The third fix is to mark the c1 variable as unused, since it truly is neither read nor written. Change-Id: I4793352b9d3e58f1f4cac9e7581ef4b2a70b43c7 --- tests/libc_logging_test.cpp | 4 ++-- tests/stack_unwinding_test_impl.c | 2 +- tests/stdio_test.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/libc_logging_test.cpp b/tests/libc_logging_test.cpp index d9c615ef4..5b10ce3dd 100644 --- a/tests/libc_logging_test.cpp +++ b/tests/libc_logging_test.cpp @@ -53,10 +53,10 @@ TEST(libc_logging, smoke) { __libc_format_buffer(buf, sizeof(buf), "a%db", -8123); EXPECT_STREQ("a-8123b", buf); - __libc_format_buffer(buf, sizeof(buf), "a%hdb", 0x7fff0010); + __libc_format_buffer(buf, sizeof(buf), "a%hdb", static_cast(0x7fff0010)); EXPECT_STREQ("a16b", buf); - __libc_format_buffer(buf, sizeof(buf), "a%hhdb", 0x7fffff10); + __libc_format_buffer(buf, sizeof(buf), "a%hhdb", static_cast(0x7fffff10)); EXPECT_STREQ("a16b", buf); __libc_format_buffer(buf, sizeof(buf), "a%lldb", 0x1000000000LL); diff --git a/tests/stack_unwinding_test_impl.c b/tests/stack_unwinding_test_impl.c index b0099f043..7518a2cdd 100644 --- a/tests/stack_unwinding_test_impl.c +++ b/tests/stack_unwinding_test_impl.c @@ -48,7 +48,7 @@ static void noinline do_crash() { } static void noinline foo() { - char c1 __attribute__((cleanup(foo_cleanup))); + char c1 __attribute__((cleanup(foo_cleanup))) unused; do_crash(); } diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 8eb65a69b..e47f967b0 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -226,10 +226,10 @@ TEST(stdio, snprintf_smoke) { snprintf(buf, sizeof(buf), "a%db", -8123); EXPECT_STREQ("a-8123b", buf); - snprintf(buf, sizeof(buf), "a%hdb", 0x7fff0010); + snprintf(buf, sizeof(buf), "a%hdb", static_cast(0x7fff0010)); EXPECT_STREQ("a16b", buf); - snprintf(buf, sizeof(buf), "a%hhdb", 0x7fffff10); + snprintf(buf, sizeof(buf), "a%hhdb", static_cast(0x7fffff10)); EXPECT_STREQ("a16b", buf); snprintf(buf, sizeof(buf), "a%lldb", 0x1000000000LL); @@ -281,7 +281,7 @@ TEST(stdio, snprintf_smoke) { snprintf(buf, sizeof(buf), "a_%f_b", 1.23f); EXPECT_STREQ("a_1.230000_b", buf); - snprintf(buf, sizeof(buf), "a_%g_b", 3.14d); + snprintf(buf, sizeof(buf), "a_%g_b", 3.14); EXPECT_STREQ("a_3.14_b", buf); }