Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Frameworks/base: Turn on -Wall -Werror in cmds
Browse files Browse the repository at this point in the history
Fix small warnings, turn on -Wall -Werror.

Change-Id: Iab1f01a7c7ebd6ba832b75067c5e395f380a1b8b
  • Loading branch information
agampe committed Nov 7, 2014
1 parent 59701b9 commit cfedceb
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 85 deletions.
31 changes: 18 additions & 13 deletions cmds/app_process/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
app_main.cpp
app_main.cpp

LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic

LOCAL_SHARED_LIBRARIES := \
libdl \
libcutils \
libutils \
liblog \
libbinder \
libandroid_runtime
libdl \
libcutils \
libutils \
liblog \
libbinder \
libandroid_runtime

LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain

LOCAL_MODULE:= app_process
LOCAL_MULTILIB := both
LOCAL_MODULE_STEM_32 := app_process32
LOCAL_MODULE_STEM_64 := app_process64

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_EXECUTABLE)

# Create a symlink from app_process to app_process32 or 64
Expand All @@ -34,14 +37,14 @@ ifeq ($(TARGET_ARCH),arm)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
app_main.cpp
app_main.cpp

LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
liblog \
libbinder \
libandroid_runtime
libcutils \
libutils \
liblog \
libbinder \
libandroid_runtime

LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain

Expand All @@ -54,6 +57,8 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan
LOCAL_MODULE_STEM := app_process
LOCAL_ADDRESS_SANITIZER := true

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_EXECUTABLE)

endif # ifeq($(TARGET_ARCH),arm)
2 changes: 1 addition & 1 deletion cmds/app_process/app_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace android {

void app_usage()
static void app_usage()
{
fprintf(stderr,
"Usage: app_process [java-options] cmd-dir start-class-name [options]\n");
Expand Down
2 changes: 2 additions & 0 deletions cmds/backup/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ LOCAL_MODULE:= btool
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := optional

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_EXECUTABLE)
14 changes: 5 additions & 9 deletions cmds/backup/backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ using namespace android;

#include <unistd.h>

int
usage(int argc, const char** argv)
static int usage(int /* argc */, const char** argv)
{
const char* p = argv[0];

Expand All @@ -44,15 +43,13 @@ usage(int argc, const char** argv)
return 1;
}

int
perform_full_backup()
static int perform_full_backup()
{
printf("this would have written all of your data to stdout\n");
return 0;
}

int
perform_list(const char* filename)
static int perform_list(const char* filename)
{
int err;
int fd;
Expand Down Expand Up @@ -95,14 +92,13 @@ perform_list(const char* filename)
return 0;
}

int perform_print(const char* entityname, const char* filename)
static int perform_print(const char* entityname, const char* filename)
{
printf("perform_print(%s, %s);", entityname, filename);
return 0;
}

int
main(int argc, const char** argv)
int main(int argc, const char** argv)
{
if (argc <= 1) {
return perform_full_backup();
Expand Down
20 changes: 11 additions & 9 deletions cmds/bootanimation/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
bootanimation_main.cpp \
AudioPlayer.cpp \
BootAnimation.cpp
bootanimation_main.cpp \
AudioPlayer.cpp \
BootAnimation.cpp

LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

LOCAL_C_INCLUDES += external/tinyalsa/include

LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog \
libandroidfw \
libutils \
libbinder \
libcutils \
liblog \
libandroidfw \
libutils \
libbinder \
libui \
libskia \
libskia \
libEGL \
libGLESv1_CM \
libgui \
Expand Down
1 change: 0 additions & 1 deletion cmds/bootanimation/AudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ bool AudioPlayer::threadLoop()
struct pcm *pcm = NULL;
bool moreChunks = true;
const struct chunk_fmt* chunkFmt = NULL;
void* buffer = NULL;
int bufferSize;
const uint8_t* wavData;
size_t wavLength;
Expand Down
19 changes: 11 additions & 8 deletions cmds/bootanimation/BootAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>

// TODO: Fix Skia.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <SkBitmap.h>
#include <SkStream.h>
#include <SkImageDecoder.h>
#pragma GCC diagnostic pop

#include <GLES/gl.h>
#include <GLES/glext.h>
Expand Down Expand Up @@ -105,7 +109,7 @@ void BootAnimation::binderDied(const wp<IBinder>&)
status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
const char* name) {
Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
if (!asset)
if (asset == NULL)
return NO_INIT;
SkBitmap bitmap;
SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
Expand Down Expand Up @@ -164,7 +168,7 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame)
SkBitmap bitmap;
SkMemoryStream stream(frame.map->getDataPtr(), frame.map->getDataLength());
SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
if (codec) {
if (codec != NULL) {
codec->setDitherImage(false);
codec->decode(&stream, &bitmap,
kN32_SkColorType,
Expand Down Expand Up @@ -252,7 +256,7 @@ status_t BootAnimation::readyToRun() {
EGL_DEPTH_SIZE, 0,
EGL_NONE
};
EGLint w, h, dummy;
EGLint w, h;
EGLint numConfigs;
EGLConfig config;
EGLSurface surface;
Expand Down Expand Up @@ -470,7 +474,7 @@ bool BootAnimation::movie()
// Parse the description file
for (;;) {
const char* endl = strstr(s, "\n");
if (!endl) break;
if (endl == NULL) break;
String8 line(s, endl - s);
const char* l = line.string();
int fps, width, height, count, pause;
Expand Down Expand Up @@ -572,7 +576,6 @@ bool BootAnimation::movie()

const int xc = (mWidth - animation.width) / 2;
const int yc = ((mHeight - animation.height) / 2);
nsecs_t lastFrame = systemTime();
nsecs_t frameDuration = s2ns(1) / animation.fps;

Region clearReg(Rect(mWidth, mHeight));
Expand Down Expand Up @@ -620,9 +623,9 @@ bool BootAnimation::movie()
Region::const_iterator tail(clearReg.end());
glEnable(GL_SCISSOR_TEST);
while (head != tail) {
const Rect& r(*head++);
glScissor(r.left, mHeight - r.bottom,
r.width(), r.height());
const Rect& r2(*head++);
glScissor(r2.left, mHeight - r2.bottom,
r2.width(), r2.height());
glClear(GL_COLOR_BUFFER_BIT);
}
glDisable(GL_SCISSOR_TEST);
Expand Down
2 changes: 1 addition & 1 deletion cmds/bootanimation/bootanimation_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace android;

// ---------------------------------------------------------------------------

int main(int argc, char** argv)
int main()
{
#if defined(HAVE_PTHREADS)
setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_DISPLAY);
Expand Down
2 changes: 2 additions & 0 deletions cmds/idmap/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ LOCAL_C_INCLUDES := external/zlib

LOCAL_MODULE_TAGS := optional

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_EXECUTABLE)
8 changes: 4 additions & 4 deletions cmds/idmap/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace {
if (entry == NULL) {
return -1;
}
if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, (long*)crc)) {
if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, reinterpret_cast<long*>(crc))) {
return -1;
}
zip->releaseEntry(entry);
Expand Down Expand Up @@ -66,7 +66,7 @@ namespace {
fprintf(stderr, "error: write: %s\n", strerror(errno));
return -1;
}
bytesLeft -= w;
bytesLeft -= static_cast<size_t>(w);
}
return 0;
}
Expand All @@ -84,7 +84,7 @@ namespace {
}

char buf[N];
ssize_t bytesLeft = N;
size_t bytesLeft = N;
if (lseek(idmap_fd, SEEK_SET, 0) < 0) {
return true;
}
Expand All @@ -93,7 +93,7 @@ namespace {
if (r < 0) {
return true;
}
bytesLeft -= r;
bytesLeft -= static_cast<size_t>(r);
if (bytesLeft == 0) {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions cmds/idmap/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ namespace {
printe("failed to get resource name id=0x%08x\n", res_id);
return UNKNOWN_ERROR;
}
if (package) {
if (package != NULL) {
*package = String8(String16(data.package, data.packageLen));
}
if (type) {
if (type != NULL) {
*type = String8(String16(data.type, data.typeLen));
}
if (name) {
if (name != NULL) {
*name = String8(String16(data.name, data.nameLen));
}
return NO_ERROR;
Expand Down
28 changes: 2 additions & 26 deletions cmds/idmap/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,6 @@ namespace {
return String8(tmp);
}

int mkdir_p(const String8& path, uid_t uid, gid_t gid)
{
static const mode_t mode =
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH;
struct stat st;

if (stat(path.string(), &st) == 0) {
return 0;
}
if (mkdir_p(path.getPathDir(), uid, gid) < 0) {
return -1;
}
if (mkdir(path.string(), 0755) != 0) {
return -1;
}
if (chown(path.string(), uid, gid) == -1) {
return -1;
}
if (chmod(path.string(), mode) == -1) {
return -1;
}
return 0;
}

int parse_overlay_tag(const ResXMLTree& parser, const char *target_package_name)
{
const size_t N = parser.getAttributeCount();
Expand All @@ -98,7 +74,7 @@ namespace {
String16 key(parser.getAttributeName(i, &len));
if (key == String16("targetPackage")) {
const uint16_t *p = parser.getAttributeStringValue(i, &len);
if (p) {
if (p != NULL) {
target = String16(p, len);
}
} else if (key == String16("priority")) {
Expand Down Expand Up @@ -164,7 +140,7 @@ namespace {
return -1;
}
FileMap *dataMap = zip->createEntryFileMap(entry);
if (!dataMap) {
if (dataMap == NULL) {
ALOGW("%s: failed to create FileMap\n", __FUNCTION__);
return -1;
}
Expand Down
4 changes: 3 additions & 1 deletion cmds/interrupter/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := interrupter
LOCAL_MODULE_TAGS := eng tests
LOCAL_LDFLAGS := -ldl
LOCAL_CFLAGS := -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_SHARED_LIBRARY)

Expand All @@ -17,5 +18,6 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := interrupter
LOCAL_MODULE_TAGS := eng tests
LOCAL_LDFLAGS := -ldl
LOCAL_CFLAGS := -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_HOST_SHARED_LIBRARY)
include $(BUILD_HOST_SHARED_LIBRARY)
12 changes: 7 additions & 5 deletions cmds/screencap/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
screencap.cpp
screencap.cpp

LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libbinder \
libskia \
libcutils \
libutils \
libbinder \
libskia \
libui \
libgui

LOCAL_MODULE:= screencap

LOCAL_MODULE_TAGS := optional

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_EXECUTABLE)
Loading

0 comments on commit cfedceb

Please sign in to comment.