Use -Werror in system/core

* Move -Wall -Werror from cppflags to cflags.
* Fix/suppress warning on unused variables.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I1e05e96a1d0bcb2ccef1ce456504b3af57167cc5
This commit is contained in:
Chih-Hung Hsieh 2017-10-02 15:20:07 -07:00
parent 15251c24b9
commit 122352d983
21 changed files with 49 additions and 44 deletions

View file

@ -14,11 +14,10 @@
// limitations under the License.
//
libbase_cppflags = [
"-Wall",
"-Wextra",
"-Werror",
]
cc_defaults {
name: "libbase_defaults",
cflags: ["-Wall", "-Werror", "-Wextra"],
}
cc_library_headers {
name: "libbase_headers",
@ -38,6 +37,7 @@ cc_library_headers {
cc_library {
name: "libbase",
defaults: ["libbase_defaults"],
vendor_available: true,
host_supported: true,
vndk: {
@ -59,7 +59,6 @@ cc_library {
],
export_header_lib_headers: ["libbase_headers"],
cppflags: libbase_cppflags,
shared_libs: ["liblog"],
target: {
android: {
@ -102,6 +101,7 @@ cc_library {
// ------------------------------------------------------------------------------
cc_test {
name: "libbase_test",
defaults: ["libbase_defaults"],
host_supported: true,
srcs: [
"endian_test.cpp",
@ -133,7 +133,6 @@ cc_test {
},
},
local_include_dirs: ["."],
cppflags: libbase_cppflags,
shared_libs: ["libbase"],
compile_multilib: "both",
multilib: {

View file

@ -1,7 +1,7 @@
cc_defaults {
name: "crasher-defaults",
cppflags: [
cflags: [
"-W",
"-Wall",
"-Wextra",

View file

@ -20,7 +20,11 @@ cc_defaults {
misc_undefined: ["integer"],
},
local_include_dirs: ["include/"],
cppflags: ["-Werror"],
cflags: [
"-Wall",
"-Werror",
"-Wno-unused-variable",
],
}
cc_library_static {

View file

@ -20,7 +20,7 @@ cc_defaults {
sanitize: {
misc_undefined: ["signed-integer-overflow"],
},
cppflags: [
cflags: [
"-DLOG_UEVENTS=0",
"-Wall",
"-Wextra",

View file

@ -17,6 +17,7 @@
cc_binary {
name: "test_service",
srcs: ["test_service.cpp"],
cflags: ["-Wall", "-Werror"],
shared_libs: ["libbase"],
init_rc: ["test_service.rc"],
}

View file

@ -59,7 +59,6 @@ int main(int argc, char* argv[]) {
}
bool test_fails = false;
size_t uargc = static_cast<size_t>(argc); // |argc| >= 3.
for (size_t i = 1; i < static_cast<size_t>(argc); i = i + 2) {
std::string expected_value = argv[i + 1];
auto f = fields.find(argv[i]);

View file

@ -14,20 +14,19 @@
// limitations under the License.
//
libasyncio_cppflags = [
"-Wall",
"-Wextra",
"-Werror",
]
cc_defaults {
name: "libasyncio_defaults",
cflags: ["-Wall", "-Werror", "-Wextra"],
}
cc_library {
name: "libasyncio",
defaults: ["libasyncio_defaults"],
vendor_available: true,
host_supported: true,
srcs: [
"AsyncIO.cpp",
],
cppflags: libasyncio_cppflags,
export_include_dirs: ["include"],
target: {

View file

@ -15,9 +15,12 @@
cc_library_static {
name: "libgrallocusage",
vendor_available: true,
cflags: [
"-Wall",
"-Werror",
],
cppflags: [
"-Weverything",
"-Werror",
"-Wno-c++98-compat-pedantic",
// Hide errors in headers we include
"-Wno-global-constructors",

View file

@ -2,6 +2,7 @@ cc_library {
name: "libpackagelistparser",
srcs: ["packagelistparser.c"],
cflags: ["-Wall", "-Werror"],
shared_libs: ["liblog"],
local_include_dirs: ["include"],
export_include_dirs: ["include"],

View file

@ -14,14 +14,14 @@
// limitations under the License.
//
libprocinfo_cppflags = [
"-Wall",
"-Wextra",
"-Werror",
]
cc_defaults {
name: "libprocinfo_defaults",
cflags: ["-Wall", "-Werror", "-Wextra"],
}
cc_library {
name: "libprocinfo",
defaults: ["libprocinfo_defaults"],
vendor_available: true,
vndk: {
enabled: true,
@ -30,7 +30,6 @@ cc_library {
srcs: [
"process.cpp",
],
cppflags: libprocinfo_cppflags,
local_include_dirs: ["include"],
export_include_dirs: ["include"],
@ -52,6 +51,7 @@ cc_library {
// ------------------------------------------------------------------------------
cc_test {
name: "libprocinfo_test",
defaults: ["libprocinfo_defaults"],
host_supported: true,
srcs: [
"process_test.cpp",
@ -65,7 +65,6 @@ cc_test {
},
},
cppflags: libprocinfo_cppflags,
shared_libs: ["libbase", "libprocinfo"],
compile_multilib: "both",

View file

@ -75,7 +75,7 @@ cc_library {
"misc.cpp",
],
cflags: ["-Werror"],
cflags: ["-Wall", "-Werror"],
include_dirs: ["external/safe-iop/include"],
header_libs: [
"libutils_headers",
@ -154,6 +154,7 @@ cc_test {
static_libs: ["libutils"],
shared_libs: ["liblog"],
srcs: ["SharedBufferTest.cpp"],
cflags: ["-Wall", "-Werror"],
}
subdirs = ["tests"]

View file

@ -410,8 +410,7 @@ void RefBase::incStrong(const void* id) const
return;
}
int32_t old = refs->mStrong.fetch_sub(INITIAL_STRONG_VALUE,
std::memory_order_relaxed);
int32_t old __unused = refs->mStrong.fetch_sub(INITIAL_STRONG_VALUE, std::memory_order_relaxed);
// A decStrong() must still happen after us.
ALOG_ASSERT(old > INITIAL_STRONG_VALUE, "0x%x too small", old);
refs->mBase->onFirstRef();

View file

@ -30,10 +30,7 @@
namespace android {
StopWatch::StopWatch(const char *name, int clock, uint32_t flags)
: mName(name), mClock(clock), mFlags(flags)
{
StopWatch::StopWatch(const char* name, int clock) : mName(name), mClock(clock) {
reset();
}

View file

@ -29,21 +29,18 @@ namespace android {
class StopWatch
{
public:
StopWatch( const char *name,
int clock = SYSTEM_TIME_MONOTONIC,
uint32_t flags = 0);
~StopWatch();
const char* name() const;
nsecs_t lap();
nsecs_t elapsedTime() const;
StopWatch(const char* name, int clock = SYSTEM_TIME_MONOTONIC);
~StopWatch();
const char* name() const;
nsecs_t lap();
nsecs_t elapsedTime() const;
void reset();
void reset();
private:
const char* mName;
int mClock;
uint32_t mFlags;
struct lap_t {
nsecs_t soFar;

View file

@ -77,6 +77,7 @@ cc_test_library {
host_supported: true,
relative_install_path: "libutils_tests",
srcs: ["Singleton_test1.cpp"],
cflags: ["-Wall", "-Werror"],
}
cc_test_library {
@ -84,5 +85,6 @@ cc_test_library {
host_supported: true,
relative_install_path: "libutils_tests",
srcs: ["Singleton_test2.cpp"],
cflags: ["-Wall", "-Werror"],
shared_libs: ["libutils_tests_singleton1"],
}

View file

@ -3,6 +3,7 @@ subdirs = ["tests"]
cc_library {
name: "libvndksupport",
srcs: ["linker.c"],
cflags: ["-Wall", "-Werror"],
local_include_dirs: ["include/vndksupport"],
export_include_dirs: ["include"],
shared_libs: ["liblog"],

View file

@ -17,6 +17,7 @@ cc_test {
srcs: [
"linker_test.cpp",
],
cflags: ["-Wall", "-Werror"],
host_supported: false,
shared_libs: [

View file

@ -30,6 +30,7 @@ cc_binary {
"trusty_keymaster_ipc.cpp",
"trusty_keymaster_main.cpp",
],
cflags: ["-Wall", "-Werror"],
shared_libs: [
"libcrypto",
"libcutils",

View file

@ -289,7 +289,6 @@ static bool test_import_ecdsa(TrustyKeymasterDevice* device) {
std::unique_ptr<const uint8_t[]> deleter(key.key_material);
printf("=== Signing with imported ECDSA key ===\n");
keymaster_ec_sign_params_t sign_params = {DIGEST_NONE};
size_t message_len = 30 /* arbitrary */;
std::unique_ptr<uint8_t[]> message(new uint8_t[message_len]);
memset(message.get(), 'a', message_len);

View file

@ -21,6 +21,7 @@ cc_library {
srcs: ["trusty.c"],
export_include_dirs: ["include"],
cflags: ["-Wall", "-Werror"],
shared_libs: ["liblog"],
}

View file

@ -23,4 +23,5 @@ cc_test {
"liblog",
],
gtest: false,
cflags: ["-Wall", "-Werror"],
}