Skip to content

Commit

Permalink
Turn on warnings (and handle them as errors)
Browse files Browse the repository at this point in the history
This helped to find a bug and keep the code clean.
  • Loading branch information
rovo89 committed Nov 15, 2015
1 parent bbf9463 commit 2d27804
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ LOCAL_SHARED_LIBRARIES := \
libandroid_runtime \
libdl

LOCAL_CFLAGS += -Wall -Werror -Wextra -Wunused -Wunreachable-code
LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)

ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \>= 17)))
Expand Down
2 changes: 1 addition & 1 deletion xposed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "xposed_safemode.h"
#include "xposed_service.h"

#include <cstring>
#include <ctype.h>
#include <cutils/process_name.h>
#include <cutils/properties.h>
Expand Down Expand Up @@ -365,7 +366,6 @@ void onVmCreated(JNIEnv* env) {
}

// Load the suitable libxposed_*.so for it
const char *error;
void* xposedLibHandle = dlopen(xposedLibPath, RTLD_NOW);
if (!xposedLibHandle) {
ALOGE("Could not load libxposed: %s", dlerror());
Expand Down
6 changes: 3 additions & 3 deletions xposed.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

#if XPOSED_WITH_SELINUX
#include <selinux/selinux.h>
static security_context_t ctx_system = (security_context_t) "u:r:system_server:s0";
#define ctx_system ((security_context_t) "u:r:system_server:s0")
#if PLATFORM_SDK_VERSION >= 23
static security_context_t ctx_app = (security_context_t) "u:r:untrusted_app:s0:c512,c768";
#define ctx_app ((security_context_t) "u:r:untrusted_app:s0:c512,c768")
#else
static security_context_t ctx_app = (security_context_t) "u:r:untrusted_app:s0";
#define ctx_app ((security_context_t) "u:r:untrusted_app:s0")
#endif // PLATFORM_SDK_VERSION >= 23
#endif // XPOSED_WITH_SELINUX

Expand Down
1 change: 1 addition & 0 deletions xposed_logcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#define LOG_TAG "Xposed"

#include <cstring>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
Expand Down
2 changes: 2 additions & 0 deletions xposed_safemode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
*/
#include "xposed_safemode.h"

#include <cstring>
#include <dirent.h>
#include <fcntl.h>
#include <linux/input.h>
#include <sys/epoll.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>

#define INITIAL_DELAY 2
#define DETECTION_TIMEOUT 5
Expand Down
11 changes: 4 additions & 7 deletions xposed_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ int accessFile(const char* path, int mode) {

callService(OP_ACCESS_FILE);

bail:
makeIdle();
errno = shared->error;
return shared->error ? -1 : data->result;
Expand All @@ -307,7 +306,6 @@ int statFile(const char* path, struct stat* st) {

memcpy(st, &data->st, sizeof(struct stat));

bail:
makeIdle();
errno = shared->error;
return shared->error ? -1 : data->result;
Expand Down Expand Up @@ -468,8 +466,8 @@ class BpXposedService: public BpInterface<IXposedService> {

int64_t size1 = reply.readInt64();
int64_t mtime1 = reply.readInt64();
if (size != NULL) size1 = *size;
if (mtime != NULL) mtime1 = *mtime;
if (size != NULL) *size = size1;
if (mtime != NULL) *mtime = mtime1;
return 0;
}

Expand Down Expand Up @@ -547,7 +545,6 @@ status_t BnXposedService::onTransact(uint32_t code, const Parcel& data, Parcel*
case STAT_FILE_TRANSACTION: {
CHECK_INTERFACE(IXposedService, data, reply);
String16 filename = data.readString16();
int32_t mode = data.readInt32();
int64_t size, time;
status_t result = statFile(filename, &size, &time);
int err = errno;
Expand Down Expand Up @@ -721,14 +718,14 @@ status_t XposedService::readFile(const String16& filename16, int32_t offset, int

// Check range
if (offset > 0 && offset >= *size) {
if (errormsg) *errormsg = formatToString16("offset %d >= size %"PRId64" for %s", offset, *size, filename);
if (errormsg) *errormsg = formatToString16("offset %d >= size %" PRId64 " for %s", offset, *size, filename);
return EINVAL;
} else if (offset < 0) {
offset = 0;
}

if (length > 0 && (offset + length) > *size) {
if (errormsg) *errormsg = formatToString16("offset %d + length %d > size %"PRId64" for %s", offset, length, *size, filename);
if (errormsg) *errormsg = formatToString16("offset %d + length %d > size %" PRId64 " for %s", offset, length, *size, filename);
return EINVAL;
} else if (*size == 0) {
*bytesRead = 0;
Expand Down

0 comments on commit 2d27804

Please sign in to comment.