summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2017-10-03 09:57:55 -0700
committerChih-Hung Hsieh <chh@google.com>2017-10-13 16:25:16 -0700
commitc7edf078f92c7ce083f8c243a79f8aecdfff4ac1 (patch)
treed7816094d61913df8ee8c17e60763ccd050c4631
parent26817938f6966928488e92de73359c3887006642 (diff)
Use -Werror in frameworks/base
* Fix unused variable and return value warnings. Bug: 66996870 Test: build with WITH_TIDY=1 Change-Id: I890e65a20848d00559ba5a4f9691be1347b456af
-rw-r--r--Android.bp5
-rw-r--r--cmds/am/Android.bp1
-rw-r--r--tools/bit/Android.bp5
-rw-r--r--tools/bit/adb.cpp4
-rw-r--r--tools/bit/command.cpp4
-rw-r--r--tools/bit/main.cpp14
-rw-r--r--tools/bit/util.cpp5
-rw-r--r--tools/incident_report/Android.bp2
-rw-r--r--tools/incident_report/printer.cpp1
-rw-r--r--tools/incident_section_gen/Android.bp2
10 files changed, 34 insertions, 9 deletions
diff --git a/Android.bp b/Android.bp
index b83c63fdf3a1..cf9610d98ba9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -34,6 +34,11 @@ cc_library {
include_dirs: ["external/protobuf/src"],
},
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
target: {
host: {
proto: {
diff --git a/cmds/am/Android.bp b/cmds/am/Android.bp
index 7eb4edfecbf9..bb16df1d159d 100644
--- a/cmds/am/Android.bp
+++ b/cmds/am/Android.bp
@@ -4,6 +4,7 @@
cc_library_host_static {
name: "libinstrumentation",
srcs: ["**/*.proto"],
+ cflags: ["-Wall", "-Werror"],
proto: {
type: "full",
export_proto_headers: true,
diff --git a/tools/bit/Android.bp b/tools/bit/Android.bp
index 258e9b517f6d..a8062719d586 100644
--- a/tools/bit/Android.bp
+++ b/tools/bit/Android.bp
@@ -30,6 +30,11 @@ cc_binary_host {
"util.cpp",
],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
static_libs: [
"libexpat",
"libinstrumentation",
diff --git a/tools/bit/adb.cpp b/tools/bit/adb.cpp
index 0c8424de566d..93fda5434307 100644
--- a/tools/bit/adb.cpp
+++ b/tools/bit/adb.cpp
@@ -293,7 +293,9 @@ run_instrumentation_test(const string& packageName, const string& runner, const
print_command(cmd);
int fds[2];
- pipe(fds);
+ if (0 != pipe(fds)) {
+ return errno;
+ }
pid_t pid = fork();
diff --git a/tools/bit/command.cpp b/tools/bit/command.cpp
index 9a8449bf9356..1ff7c221b26e 100644
--- a/tools/bit/command.cpp
+++ b/tools/bit/command.cpp
@@ -105,7 +105,9 @@ get_command_output(const Command& command, int* err, bool quiet)
}
int fds[2];
- pipe(fds);
+ if (0 != pipe(fds)) {
+ return string();
+ }
pid_t pid = fork();
diff --git a/tools/bit/main.cpp b/tools/bit/main.cpp
index d056ba53ca84..ad23971152b2 100644
--- a/tools/bit/main.cpp
+++ b/tools/bit/main.cpp
@@ -561,6 +561,15 @@ check_device_property(const string& property, const string& expected)
}
}
+static void
+chdir_or_exit(const char *path) {
+ // TODO: print_command("cd", path);
+ if (0 != chdir(path)) {
+ print_error("Error: Could not chdir: %s", path);
+ exit(1);
+ }
+}
+
/**
* Run the build, install, and test actions.
*/
@@ -583,8 +592,7 @@ run_phases(vector<Target*> targets, const Options& options)
const string buildId = get_build_var(buildTop, "BUILD_ID", false);
const string buildOut = get_out_dir();
- // TODO: print_command("cd", buildTop.c_str());
- chdir(buildTop.c_str());
+ chdir_or_exit(buildTop.c_str());
// Get the modules for the targets
map<string,Module> modules;
@@ -952,7 +960,7 @@ run_tab_completion(const string& word)
const string buildProduct = get_required_env("TARGET_PRODUCT", false);
const string buildOut = get_out_dir();
- chdir(buildTop.c_str());
+ chdir_or_exit(buildTop.c_str());
string buildDevice = sniff_device_name(buildOut, buildProduct);
diff --git a/tools/bit/util.cpp b/tools/bit/util.cpp
index fc93bcb8c935..922393146b10 100644
--- a/tools/bit/util.cpp
+++ b/tools/bit/util.cpp
@@ -101,7 +101,6 @@ TrackedFile::HasChanged() const
void
get_directory_contents(const string& name, map<string,FileInfo>* results)
{
- int err;
DIR* dir = opendir(name.c_str());
if (dir == NULL) {
return;
@@ -241,7 +240,9 @@ read_file(const string& filename)
fseek(file, 0, SEEK_SET);
char* buf = (char*)malloc(size);
- fread(buf, 1, size, file);
+ if ((size_t) size != fread(buf, 1, size, file)) {
+ return string();
+ }
string result(buf, size);
diff --git a/tools/incident_report/Android.bp b/tools/incident_report/Android.bp
index ab55dbd81821..f2d0d0f3e553 100644
--- a/tools/incident_report/Android.bp
+++ b/tools/incident_report/Android.bp
@@ -31,5 +31,5 @@ cc_binary_host {
"libprotobuf-cpp-full",
],
- cflags: ["-Wno-unused-parameter"],
+ cflags: ["-Wall", "-Werror"],
}
diff --git a/tools/incident_report/printer.cpp b/tools/incident_report/printer.cpp
index bd660dd20dfd..bff1025ad8da 100644
--- a/tools/incident_report/printer.cpp
+++ b/tools/incident_report/printer.cpp
@@ -70,7 +70,6 @@ Out::printf(const char* format, ...)
len = vsnprintf(mBuf, mBufSize, format, args);
va_end(args);
- bool truncated = (len >= mBufSize) && (reallocate(len) < len);
va_start(args, format);
len = vsnprintf(mBuf, mBufSize, format, args);
diff --git a/tools/incident_section_gen/Android.bp b/tools/incident_section_gen/Android.bp
index 1756e06c66fa..f07445a17781 100644
--- a/tools/incident_section_gen/Android.bp
+++ b/tools/incident_section_gen/Android.bp
@@ -22,6 +22,8 @@ cc_binary_host {
cflags: [
"-g",
"-O0",
+ "-Wall",
+ "-Werror",
],
srcs: ["main.cpp"],
shared_libs: [