Turn on -Wall for recovery modules

Turn on -Wall for all modules. Also remove the obsolete file_cmp() in
apply_patch test and now() in wear_ui.

The only exception is lib_edify due to the unused functions in the
intermediate cpp files generated from the lex files. It will be handled
in a seperate CL.

Bug: 64939312
Test: mma, unit tests pass
Change-Id: Ic53f76b60b6401ab20db3d98130d674c08e3702f
This commit is contained in:
Tianjie Xu 2017-08-28 14:15:07 -07:00
parent e9605b8ca0
commit c89d1e7e2a
12 changed files with 34 additions and 35 deletions

View file

@ -93,7 +93,7 @@ endif
endif endif
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
LOCAL_CFLAGS += -Wno-unused-parameter -Werror LOCAL_CFLAGS += -Wall -Wno-unused-parameter -Werror
ifneq ($(TARGET_RECOVERY_UI_MARGIN_HEIGHT),) ifneq ($(TARGET_RECOVERY_UI_MARGIN_HEIGHT),)
LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_HEIGHT=$(TARGET_RECOVERY_UI_MARGIN_HEIGHT) LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_HEIGHT=$(TARGET_RECOVERY_UI_MARGIN_HEIGHT)
@ -203,7 +203,7 @@ LOCAL_SRC_FILES := \
rotate_logs.cpp rotate_logs.cpp
LOCAL_MODULE := recovery-persist LOCAL_MODULE := recovery-persist
LOCAL_SHARED_LIBRARIES := liblog libbase LOCAL_SHARED_LIBRARIES := liblog libbase
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_INIT_RC := recovery-persist.rc LOCAL_INIT_RC := recovery-persist.rc
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
@ -215,7 +215,7 @@ LOCAL_SRC_FILES := \
rotate_logs.cpp rotate_logs.cpp
LOCAL_MODULE := recovery-refresh LOCAL_MODULE := recovery-refresh
LOCAL_SHARED_LIBRARIES := liblog libbase LOCAL_SHARED_LIBRARIES := liblog libbase
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_INIT_RC := recovery-refresh.rc LOCAL_INIT_RC := recovery-refresh.rc
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
@ -230,13 +230,14 @@ LOCAL_STATIC_LIBRARIES := \
libcrypto_utils \ libcrypto_utils \
libcrypto \ libcrypto \
libbase libbase
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
# Wear default device # Wear default device
# =============================== # ===============================
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_SRC_FILES := wear_device.cpp LOCAL_SRC_FILES := wear_device.cpp
LOCAL_CFLAGS := -Wall -Werror
# Should match TARGET_RECOVERY_UI_LIB in BoardConfig.mk. # Should match TARGET_RECOVERY_UI_LIB in BoardConfig.mk.
LOCAL_MODULE := librecovery_ui_wear LOCAL_MODULE := librecovery_ui_wear
@ -248,6 +249,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_SRC_FILES := vr_device.cpp LOCAL_SRC_FILES := vr_device.cpp
LOCAL_CFLAGS := -Wall -Werror
# should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk # should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk
LOCAL_MODULE := librecovery_ui_vr LOCAL_MODULE := librecovery_ui_vr

View file

@ -37,6 +37,7 @@ LOCAL_STATIC_LIBRARIES := \
libz libz
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-DZLIB_CONST \ -DZLIB_CONST \
-Wall \
-Werror -Werror
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@ -59,6 +60,7 @@ LOCAL_STATIC_LIBRARIES := \
libz libz
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-DZLIB_CONST \ -DZLIB_CONST \
-Wall \
-Werror -Werror
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@ -82,6 +84,7 @@ LOCAL_STATIC_LIBRARIES := \
libz libz
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-DZLIB_CONST \ -DZLIB_CONST \
-Wall \
-Werror -Werror
include $(BUILD_HOST_STATIC_LIBRARY) include $(BUILD_HOST_STATIC_LIBRARY)
@ -97,7 +100,7 @@ LOCAL_STATIC_LIBRARIES := \
libbase \ libbase \
libedify \ libedify \
libcrypto libcrypto
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
# applypatch (target executable) # applypatch (target executable)
@ -119,13 +122,14 @@ LOCAL_SHARED_LIBRARIES := \
libbase \ libbase \
libz \ libz \
libcutils libcutils
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
libimgdiff_src_files := imgdiff.cpp libimgdiff_src_files := imgdiff.cpp
# libbsdiff is compiled with -D_FILE_OFFSET_BITS=64. # libbsdiff is compiled with -D_FILE_OFFSET_BITS=64.
libimgdiff_cflags := \ libimgdiff_cflags := \
-Wall \
-Werror \ -Werror \
-D_FILE_OFFSET_BITS=64 \ -D_FILE_OFFSET_BITS=64 \
-DZLIB_CONST -DZLIB_CONST
@ -177,7 +181,7 @@ include $(BUILD_HOST_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_SRC_FILES := imgdiff_main.cpp LOCAL_SRC_FILES := imgdiff_main.cpp
LOCAL_MODULE := imgdiff LOCAL_MODULE := imgdiff
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_STATIC_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \
libimgdiff \ libimgdiff \
$(libimgdiff_static_libraries) \ $(libimgdiff_static_libraries) \

View file

@ -17,7 +17,10 @@
cc_library_static { cc_library_static {
name: "libbootloader_message", name: "libbootloader_message",
srcs: ["bootloader_message.cpp"], srcs: ["bootloader_message.cpp"],
cppflags: ["-Werror"], cppflags: [
"-Wall",
"-Werror",
],
static_libs: [ static_libs: [
"libbase", "libbase",
"libfs_mgr", "libfs_mgr",

View file

@ -32,7 +32,7 @@ LOCAL_STATIC_LIBRARIES := \
libpng \ libpng \
libbase libbase
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
@ -68,7 +68,7 @@ LOCAL_SHARED_LIBRARIES := \
libpng \ libpng \
libbase libbase
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)

View file

@ -24,6 +24,7 @@ otafault_static_libs := \
liblog liblog
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-Wall \
-Werror \ -Werror \
-Wthread-safety \ -Wthread-safety \
-Wthread-safety-negative \ -Wthread-safety-negative \
@ -46,7 +47,7 @@ LOCAL_SRC_FILES := config.cpp ota_io.cpp test.cpp
LOCAL_MODULE_TAGS := tests LOCAL_MODULE_TAGS := tests
LOCAL_MODULE := otafault_test LOCAL_MODULE := otafault_test
LOCAL_STATIC_LIBRARIES := $(otafault_static_libs) LOCAL_STATIC_LIBRARIES := $(otafault_static_libs)
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_C_INCLUDES := bootable/recovery LOCAL_C_INCLUDES := bootable/recovery
LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_FORCE_STATIC_EXECUTABLE := true

View file

@ -69,7 +69,9 @@ std::string fault_fname(const char* io_type) {
fname.resize(OTAIO_MAX_FNAME_SIZE); fname.resize(OTAIO_MAX_FNAME_SIZE);
ZipString zip_type_path(type_path.c_str()); ZipString zip_type_path(type_path.c_str());
ZipEntry entry; ZipEntry entry;
int status = FindEntry(archive, zip_type_path, &entry); if (FindEntry(archive, zip_type_path, &entry) != 0) {
return {};
}
ExtractToMemory(archive, &entry, reinterpret_cast<uint8_t*>(&fname[0]), OTAIO_MAX_FNAME_SIZE); ExtractToMemory(archive, &entry, reinterpret_cast<uint8_t*>(&fname[0]), OTAIO_MAX_FNAME_SIZE);
return fname; return fname;
} }

View file

@ -32,15 +32,15 @@ static std::string print_sha1(const uint8_t* sha1, size_t len) {
return result; return result;
} }
static std::string print_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) { [[maybe_unused]] static std::string print_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) {
return print_sha1(sha1, SHA_DIGEST_LENGTH); return print_sha1(sha1, SHA_DIGEST_LENGTH);
} }
static std::string short_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) { [[maybe_unused]] static std::string short_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) {
return print_sha1(sha1, 4); return print_sha1(sha1, 4);
} }
static std::string print_hex(const uint8_t* bytes, size_t len) { [[maybe_unused]] static std::string print_hex(const uint8_t* bytes, size_t len) {
return print_sha1(bytes, len); return print_sha1(bytes, len);
} }

View file

@ -18,7 +18,7 @@ LOCAL_PATH := $(call my-dir)
# Unit tests # Unit tests
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_MODULE := recovery_unit_test LOCAL_MODULE := recovery_unit_test
LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_STATIC_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \
@ -46,7 +46,7 @@ include $(BUILD_NATIVE_TEST)
# Manual tests # Manual tests
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_MODULE := recovery_manual_test LOCAL_MODULE := recovery_manual_test
LOCAL_STATIC_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \
libminui \ libminui \
@ -81,6 +81,7 @@ include $(BUILD_NATIVE_TEST)
# Component tests # Component tests
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-Wall \
-Werror \ -Werror \
-D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64
@ -191,7 +192,7 @@ include $(BUILD_NATIVE_TEST)
# Host tests # Host tests
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_MODULE := recovery_host_test LOCAL_MODULE := recovery_host_test
LOCAL_MODULE_HOST_OS := linux LOCAL_MODULE_HOST_OS := linux
LOCAL_C_INCLUDES := bootable/recovery LOCAL_C_INCLUDES := bootable/recovery

View file

@ -61,14 +61,6 @@ static void mangle_file(const std::string& fname) {
ASSERT_TRUE(android::base::WriteStringToFile(content, fname)); ASSERT_TRUE(android::base::WriteStringToFile(content, fname));
} }
static bool file_cmp(const std::string& f1, const std::string& f2) {
std::string c1;
android::base::ReadFileToString(f1, &c1);
std::string c2;
android::base::ReadFileToString(f2, &c2);
return c1 == c2;
}
class ApplyPatchTest : public ::testing::Test { class ApplyPatchTest : public ::testing::Test {
public: public:
static void SetUpTestCase() { static void SetUpTestCase() {

View file

@ -25,7 +25,7 @@ LOCAL_STATIC_LIBRARIES := \
liblog \ liblog \
libfs_mgr \ libfs_mgr \
libcutils libcutils
LOCAL_CFLAGS := -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_INIT_RC := uncrypt.rc LOCAL_INIT_RC := uncrypt.rc
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)

View file

@ -66,6 +66,7 @@ LOCAL_C_INCLUDES := \
external/e2fsprogs/misc external/e2fsprogs/misc
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-Wall \
-Wno-unused-parameter \ -Wno-unused-parameter \
-Werror -Werror
@ -91,6 +92,7 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include $(LOCAL_PATH)/include
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-Wall \
-Wno-unused-parameter \ -Wno-unused-parameter \
-Werror -Werror

View file

@ -39,13 +39,6 @@
#include "common.h" #include "common.h"
#include "device.h" #include "device.h"
// Return the current time as a double (including fractions of a second).
static double now() {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
WearRecoveryUI::WearRecoveryUI() WearRecoveryUI::WearRecoveryUI()
: kProgressBarBaseline(RECOVERY_UI_PROGRESS_BAR_BASELINE), : kProgressBarBaseline(RECOVERY_UI_PROGRESS_BAR_BASELINE),
kMenuUnusableRows(RECOVERY_UI_MENU_UNUSABLE_ROWS) { kMenuUnusableRows(RECOVERY_UI_MENU_UNUSABLE_ROWS) {
@ -167,7 +160,6 @@ void WearRecoveryUI::draw_screen_locked() {
// display from the bottom up, until we hit the top of the // display from the bottom up, until we hit the top of the
// screen, the bottom of the menu, or we've displayed the // screen, the bottom of the menu, or we've displayed the
// entire text buffer. // entire text buffer.
int ty;
int row = (text_top_ + text_rows_ - 1) % text_rows_; int row = (text_top_ + text_rows_ - 1) % text_rows_;
size_t count = 0; size_t count = 0;
for (int ty = gr_fb_height() - char_height_ - kMarginHeight; ty > y + 2 && count < text_rows_; for (int ty = gr_fb_height() - char_height_ - kMarginHeight; ty > y + 2 && count < text_rows_;