summaryrefslogtreecommitdiffstats
path: root/cmds/idmap
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/idmap')
-rw-r--r--cmds/idmap/Android.mk2
-rw-r--r--cmds/idmap/create.cpp11
-rw-r--r--cmds/idmap/inspect.cpp6
-rw-r--r--cmds/idmap/scan.cpp45
4 files changed, 22 insertions, 42 deletions
diff --git a/cmds/idmap/Android.mk b/cmds/idmap/Android.mk
index ffa83f2..50ccb07 100644
--- a/cmds/idmap/Android.mk
+++ b/cmds/idmap/Android.mk
@@ -25,4 +25,6 @@ LOCAL_C_INCLUDES := external/zlib
LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
include $(BUILD_EXECUTABLE)
diff --git a/cmds/idmap/create.cpp b/cmds/idmap/create.cpp
index 593a197..16532b8 100644
--- a/cmds/idmap/create.cpp
+++ b/cmds/idmap/create.cpp
@@ -7,6 +7,7 @@
#include <utils/String8.h>
#include <fcntl.h>
+#include <sys/file.h>
#include <sys/stat.h>
using namespace android;
@@ -22,7 +23,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);
@@ -66,7 +67,7 @@ fail:
fprintf(stderr, "error: write: %s\n", strerror(errno));
return -1;
}
- bytesLeft -= w;
+ bytesLeft -= static_cast<size_t>(w);
}
return 0;
}
@@ -78,13 +79,13 @@ fail:
if (fstat(idmap_fd, &st) == -1) {
return true;
}
- if (st.st_size < N) {
+ if (st.st_size < static_cast<off_t>(N)) {
// file is empty or corrupt
return true;
}
char buf[N];
- ssize_t bytesLeft = N;
+ size_t bytesLeft = N;
if (lseek(idmap_fd, SEEK_SET, 0) < 0) {
return true;
}
@@ -93,7 +94,7 @@ fail:
if (r < 0) {
return true;
}
- bytesLeft -= r;
+ bytesLeft -= static_cast<size_t>(r);
if (bytesLeft == 0) {
break;
}
diff --git a/cmds/idmap/inspect.cpp b/cmds/idmap/inspect.cpp
index b9ac8a5..f6afc85 100644
--- a/cmds/idmap/inspect.cpp
+++ b/cmds/idmap/inspect.cpp
@@ -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;
diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp
index 1153f38..84158d3 100644
--- a/cmds/idmap/scan.cpp
+++ b/cmds/idmap/scan.cpp
@@ -1,3 +1,6 @@
+#include <dirent.h>
+#include <sys/stat.h>
+
#include "idmap.h"
#include <UniquePtr.h>
@@ -9,8 +12,6 @@
#include <utils/String16.h>
#include <utils/String8.h>
-#include <dirent.h>
-
#define NO_OVERLAY_TAG (-1000)
using namespace android;
@@ -64,30 +65,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();
@@ -97,8 +74,8 @@ namespace {
size_t len;
String16 key(parser.getAttributeName(i, &len));
if (key == String16("targetPackage")) {
- const uint16_t *p = parser.getAttributeStringValue(i, &len);
- if (p) {
+ const char16_t *p = parser.getAttributeStringValue(i, &len);
+ if (p != NULL) {
target = String16(p, len);
}
} else if (key == String16("priority")) {
@@ -164,27 +141,27 @@ namespace {
return -1;
}
FileMap *dataMap = zip->createEntryFileMap(entry);
- if (!dataMap) {
+ if (dataMap == NULL) {
ALOGW("%s: failed to create FileMap\n", __FUNCTION__);
return -1;
}
char *buf = new char[uncompLen];
if (NULL == buf) {
- ALOGW("%s: failed to allocate %d byte\n", __FUNCTION__, uncompLen);
- dataMap->release();
+ ALOGW("%s: failed to allocate %zd byte\n", __FUNCTION__, uncompLen);
+ delete dataMap;
return -1;
}
StreamingZipInflater inflater(dataMap, uncompLen);
if (inflater.read(buf, uncompLen) < 0) {
- ALOGW("%s: failed to inflate %d byte\n", __FUNCTION__, uncompLen);
+ ALOGW("%s: failed to inflate %zd byte\n", __FUNCTION__, uncompLen);
delete[] buf;
- dataMap->release();
+ delete dataMap;
return -1;
}
int priority = parse_manifest(buf, uncompLen, target_package_name);
delete[] buf;
- dataMap->release();
+ delete dataMap;
return priority;
}
}