Merge "Rewrite unwind thread handling."
diff --git a/adb/Android.mk b/adb/Android.mk
index 62f012c..50e28a6 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -74,7 +74,7 @@
LOCAL_SRC_FILES += fdevent.c
endif
-LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter
+LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter -Werror
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
LOCAL_MODULE := adb
LOCAL_MODULE_TAGS := debug
@@ -116,7 +116,7 @@
remount_service.c \
usb_linux_client.c
-LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
+LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter -Werror
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
@@ -138,8 +138,6 @@
ifneq ($(SDK_ONLY),true)
include $(CLEAR_VARS)
-LOCAL_LDLIBS := -lrt -ldl -lpthread
-
LOCAL_SRC_FILES := \
adb.c \
console.c \
@@ -162,8 +160,7 @@
-g \
-DADB_HOST=1 \
-DADB_HOST_ON_TARGET=1 \
- -Wall \
- -Wno-unused-parameter \
+ -Wall -Wno-unused-parameter -Werror \
-D_XOPEN_SOURCE \
-D_GNU_SOURCE
diff --git a/adb/backup_service.c b/adb/backup_service.c
index 669ff86..654e0f3 100644
--- a/adb/backup_service.c
+++ b/adb/backup_service.c
@@ -52,15 +52,12 @@
pid_t pid;
int s[2];
char* operation;
- int socketnum;
- // Command string and choice of stdin/stdout for the pipe depend on our invocation
+ // Command string depends on our invocation
if (op == BACKUP) {
operation = "backup";
- socketnum = STDOUT_FILENO;
} else {
operation = "restore";
- socketnum = STDIN_FILENO;
}
D("backup_service(%s, %s)\n", operation, args);
diff --git a/adb/commandline.c b/adb/commandline.c
index 83b568d..241cefc 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -406,7 +406,7 @@
}
int opt = CHUNK_SIZE;
- opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt));
+ opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt));
total = sz;
ptr = data;
@@ -681,10 +681,10 @@
return 0;
}
-static int mkdirs(char *path)
+static int mkdirs(const char *path)
{
int ret;
- char *x = path + 1;
+ char *x = (char *)path + 1;
for(;;) {
x = adb_dirstart(x);
@@ -727,7 +727,7 @@
if (argc < 2) return usage();
adb_unlink(filename);
- mkdirs((char *)filename);
+ mkdirs(filename);
outFd = adb_creat(filename, 0640);
if (outFd < 0) {
fprintf(stderr, "adb: unable to open file %s\n", filename);
diff --git a/adb/file_sync_client.c b/adb/file_sync_client.c
index 8fad50e..dc4e77f 100644
--- a/adb/file_sync_client.c
+++ b/adb/file_sync_client.c
@@ -456,10 +456,10 @@
return -1;
}
-static int mkdirs(char *name)
+static int mkdirs(const char *name)
{
int ret;
- char *x = name + 1;
+ char *x = (char *)name + 1;
for(;;) {
x = adb_dirstart(x);
@@ -521,7 +521,7 @@
if((id == ID_DATA) || (id == ID_DONE)) {
adb_unlink(lpath);
- mkdirs((char *)lpath);
+ mkdirs(lpath);
lfd = adb_creat(lpath, 0644);
if(lfd < 0) {
fprintf(stderr,"cannot create '%s': %s\n", lpath, strerror(errno));
diff --git a/adb/remount_service.c b/adb/remount_service.c
index ad61284..d3a649b 100644
--- a/adb/remount_service.c
+++ b/adb/remount_service.c
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/mount.h>
#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <unistd.h>
#include "sysdeps.h"
@@ -35,7 +35,6 @@
{
int fd;
int res;
- int size;
char *token = NULL;
const char delims[] = "\n";
char buf[4096];
@@ -45,7 +44,7 @@
return NULL;
buf[sizeof(buf) - 1] = '\0';
- size = adb_read(fd, buf, sizeof(buf) - 1);
+ adb_read(fd, buf, sizeof(buf) - 1);
adb_close(fd);
token = strtok(buf, delims);
diff --git a/adb/sysdeps_win32.c b/adb/sysdeps_win32.c
index 2105b16..b0cb048 100644
--- a/adb/sysdeps_win32.c
+++ b/adb/sysdeps_win32.c
@@ -956,7 +956,7 @@
avail = len;
memcpy( bip->buff + bip->a_end, src, avail );
- src += avail;
+ src = (const char *)src + avail;
count += avail;
len -= avail;
@@ -1049,7 +1049,7 @@
avail = len;
memcpy( dst, bip->buff + bip->a_start, avail );
- dst += avail;
+ dst = (char *)dst + avail;
count += avail;
len -= avail;
diff --git a/adb/usb_windows.c b/adb/usb_windows.c
index 4936b77..1309a78 100644
--- a/adb/usb_windows.c
+++ b/adb/usb_windows.c
@@ -310,14 +310,14 @@
int xfer = (len > 4096) ? 4096 : len;
ret = AdbReadEndpointSync(handle->adb_read_pipe,
- (void*)data,
+ data,
(unsigned long)xfer,
&read,
time_out);
int saved_errno = GetLastError();
D("usb_write got: %ld, expected: %d, errno: %d\n", read, xfer, saved_errno);
if (ret) {
- data += read;
+ data = (char *)data + read;
len -= read;
if (len == 0)
diff --git a/debuggerd/mips/machine.cpp b/debuggerd/mips/machine.cpp
index 7b4e29e..ab34182 100644
--- a/debuggerd/mips/machine.cpp
+++ b/debuggerd/mips/machine.cpp
@@ -22,8 +22,6 @@
#include <sys/types.h>
#include <sys/ptrace.h>
-#include <corkscrew/ptrace.h>
-
#include <sys/user.h>
#include "../utility.h"
@@ -37,7 +35,7 @@
// If configured to do so, dump memory around *all* registers
// for the crashing thread.
void dump_memory_and_code(log_t* log, pid_t tid, int scope_flags) {
- pt_regs_mips_t r;
+ pt_regs r;
if (ptrace(PTRACE_GETREGS, tid, 0, &r)) {
return;
}
@@ -80,7 +78,7 @@
}
void dump_registers(log_t* log, pid_t tid, int scope_flags) {
- pt_regs_mips_t r;
+ pt_regs r;
if(ptrace(PTRACE_GETREGS, tid, 0, &r)) {
_LOG(log, scope_flags, "cannot get registers: %s\n", strerror(errno));
return;
diff --git a/fastboot/Android.mk b/fastboot/Android.mk
index b9b3c92..05ddf2a 100644
--- a/fastboot/Android.mk
+++ b/fastboot/Android.mk
@@ -18,7 +18,7 @@
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../mkbootimg \
$(LOCAL_PATH)/../../extras/ext4_utils
-LOCAL_SRC_FILES := protocol.c engine.c bootimg.c fastboot.c util.c
+LOCAL_SRC_FILES := protocol.c engine.c bootimg.c fastboot.c util.c fs.c
LOCAL_MODULE := fastboot
LOCAL_MODULE_TAGS := debug
LOCAL_CFLAGS += -std=gnu99
diff --git a/fastboot/engine.c b/fastboot/engine.c
index 972c4ed..5a6709b 100644
--- a/fastboot/engine.c
+++ b/fastboot/engine.c
@@ -27,7 +27,7 @@
*/
#include "fastboot.h"
-#include "make_ext4fs.h"
+#include "fs.h"
#include <errno.h>
#include <stdio.h>
@@ -51,9 +51,8 @@
#define OP_COMMAND 2
#define OP_QUERY 3
#define OP_NOTICE 4
-#define OP_FORMAT 5
-#define OP_DOWNLOAD_SPARSE 6
-#define OP_WAIT_FOR_DISCONNECT 7
+#define OP_DOWNLOAD_SPARSE 5
+#define OP_WAIT_FOR_DISCONNECT 6
typedef struct Action Action;
@@ -79,14 +78,7 @@
static Action *action_last = 0;
-struct image_data {
- long long partition_size;
- long long image_size; // real size of image file
- void *buffer;
-};
-void generate_ext4_image(struct image_data *image);
-void cleanup_image(struct image_data *image);
int fb_getvar(struct usb_handle *usb, char *response, const char *fmt, ...)
{
@@ -102,24 +94,6 @@
return fb_command_response(usb, cmd, response);
}
-struct generator {
- char *fs_type;
-
- /* generate image and return it as image->buffer.
- * size of the buffer returned as image->image_size.
- *
- * image->partition_size specifies what is the size of the
- * file partition we generate image for.
- */
- void (*generate)(struct image_data *image);
-
- /* it cleans the buffer allocated during image creation.
- * this function probably does free() or munmap().
- */
- void (*cleanup)(struct image_data *image);
-} generators[] = {
- { "ext4", generate_ext4_image, cleanup_image }
-};
/* Return true if this partition is supported by the fastboot format command.
* It is also used to determine if we should first erase a partition before
@@ -128,30 +102,20 @@
* Not all devices report the filesystem type, so don't report any errors,
* just return false.
*/
-int fb_format_supported(usb_handle *usb, const char *partition)
+int fb_format_supported(usb_handle *usb, const char *partition, const char *type_override)
{
- char response[FB_RESPONSE_SZ+1];
- struct generator *generator = NULL;
+ char fs_type[FB_RESPONSE_SZ + 1] = {0,};
int status;
unsigned int i;
- status = fb_getvar(usb, response, "partition-type:%s", partition);
+ if (type_override) {
+ return !!fs_get_generator(type_override);
+ }
+ status = fb_getvar(usb, fs_type, "partition-type:%s", partition);
if (status) {
return 0;
}
-
- for (i = 0; i < ARRAY_SIZE(generators); i++) {
- if (!strncmp(generators[i].fs_type, response, FB_RESPONSE_SZ)) {
- generator = &generators[i];
- break;
- }
- }
-
- if (generator) {
- return 1;
- }
-
- return 0;
+ return !!fs_get_generator(fs_type);
}
static int cb_default(Action *a, int status, char *resp)
@@ -205,163 +169,6 @@
a->msg = mkmsg("erasing '%s'", ptn);
}
-/* Loads file content into buffer. Returns NULL on error. */
-static void *load_buffer(int fd, off_t size)
-{
- void *buffer;
-
-#ifdef USE_MINGW
- ssize_t count = 0;
-
- // mmap is more efficient but mingw does not support it.
- // In this case we read whole image into memory buffer.
- buffer = malloc(size);
- if (!buffer) {
- perror("malloc");
- return NULL;
- }
-
- lseek(fd, 0, SEEK_SET);
- while(count < size) {
- ssize_t actually_read = read(fd, (char*)buffer+count, size-count);
-
- if (actually_read == 0) {
- break;
- }
- if (actually_read < 0) {
- if (errno == EINTR) {
- continue;
- }
- perror("read");
- free(buffer);
- return NULL;
- }
-
- count += actually_read;
- }
-#else
- buffer = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (buffer == MAP_FAILED) {
- perror("mmap");
- return NULL;
- }
-#endif
-
- return buffer;
-}
-
-void cleanup_image(struct image_data *image)
-{
-#ifdef USE_MINGW
- free(image->buffer);
-#else
- munmap(image->buffer, image->image_size);
-#endif
-}
-
-void generate_ext4_image(struct image_data *image)
-{
- int fd;
- struct stat st;
-
- fd = fileno(tmpfile());
- make_ext4fs_sparse_fd(fd, image->partition_size, NULL, NULL);
-
- fstat(fd, &st);
- image->image_size = st.st_size;
- image->buffer = load_buffer(fd, st.st_size);
-
- close(fd);
-}
-
-int fb_format(Action *a, usb_handle *usb, int skip_if_not_supported)
-{
- const char *partition = a->cmd;
- char response[FB_RESPONSE_SZ+1];
- int status = 0;
- struct image_data image;
- struct generator *generator = NULL;
- int fd;
- unsigned i;
- char cmd[CMD_SIZE];
-
- status = fb_getvar(usb, response, "partition-type:%s", partition);
- if (status) {
- if (skip_if_not_supported) {
- fprintf(stderr,
- "Erase successful, but not automatically formatting.\n");
- fprintf(stderr,
- "Can't determine partition type.\n");
- return 0;
- }
- fprintf(stderr,"FAILED (%s)\n", fb_get_error());
- return status;
- }
-
- for (i = 0; i < ARRAY_SIZE(generators); i++) {
- if (!strncmp(generators[i].fs_type, response, FB_RESPONSE_SZ)) {
- generator = &generators[i];
- break;
- }
- }
- if (!generator) {
- if (skip_if_not_supported) {
- fprintf(stderr,
- "Erase successful, but not automatically formatting.\n");
- fprintf(stderr,
- "File system type %s not supported.\n", response);
- return 0;
- }
- fprintf(stderr,"Formatting is not supported for filesystem with type '%s'.\n",
- response);
- return -1;
- }
-
- status = fb_getvar(usb, response, "partition-size:%s", partition);
- if (status) {
- if (skip_if_not_supported) {
- fprintf(stderr,
- "Erase successful, but not automatically formatting.\n");
- fprintf(stderr, "Unable to get partition size\n.");
- return 0;
- }
- fprintf(stderr,"FAILED (%s)\n", fb_get_error());
- return status;
- }
- image.partition_size = strtoll(response, (char **)NULL, 16);
-
- generator->generate(&image);
- if (!image.buffer) {
- fprintf(stderr,"Cannot generate image.\n");
- return -1;
- }
-
- // Following piece of code is similar to fb_queue_flash() but executes
- // actions directly without queuing
- fprintf(stderr, "sending '%s' (%lli KB)...\n", partition, image.image_size/1024);
- status = fb_download_data(usb, image.buffer, image.image_size);
- if (status) goto cleanup;
-
- fprintf(stderr, "writing '%s'...\n", partition);
- snprintf(cmd, sizeof(cmd), "flash:%s", partition);
- status = fb_command(usb, cmd);
- if (status) goto cleanup;
-
-cleanup:
- generator->cleanup(&image);
-
- return status;
-}
-
-void fb_queue_format(const char *partition, int skip_if_not_supported)
-{
- Action *a;
-
- a = queue_action(OP_FORMAT, partition);
- a->data = (void*)skip_if_not_supported;
- a->msg = mkmsg("formatting '%s' partition", partition);
-}
-
void fb_queue_flash(const char *ptn, void *data, unsigned sz)
{
Action *a;
@@ -589,10 +396,6 @@
if (status) break;
} else if (a->op == OP_NOTICE) {
fprintf(stderr,"%s\n",(char*)a->data);
- } else if (a->op == OP_FORMAT) {
- status = fb_format(a, usb, (int)a->data);
- status = a->func(a, status, status ? fb_get_error() : "");
- if (status) break;
} else if (a->op == OP_DOWNLOAD_SPARSE) {
status = fb_download_data_sparse(usb, a->data);
status = a->func(a, status, status ? fb_get_error() : "");
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 7d26c6f..4d3e0af 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -33,6 +33,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
+
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
@@ -49,6 +50,7 @@
#include <zipfile/zipfile.h>
#include "fastboot.h"
+#include "fs.h"
#ifndef O_BINARY
#define O_BINARY 0
@@ -99,10 +101,11 @@
char sig_name[13];
char part_name[9];
bool is_optional;
-} images[3] = {
+} images[4] = {
{"boot.img", "boot.sig", "boot", false},
{"recovery.img", "recovery.sig", "recovery", true},
{"system.img", "system.sig", "system", false},
+ {"tos.img", "tos.sig", "tos", true},
};
void get_my_path(char *path);
@@ -119,6 +122,8 @@
fn = "recovery.img";
} else if(!strcmp(item,"system")) {
fn = "system.img";
+ } else if(!strcmp(item,"tos")) {
+ fn = "tos.img";
} else if(!strcmp(item,"userdata")) {
fn = "userdata.img";
} else if(!strcmp(item,"cache")) {
@@ -284,10 +289,13 @@
"\n"
"commands:\n"
" update <filename> reflash device from update.zip\n"
- " flashall flash boot + recovery + system\n"
+ " flashall flash boot, system, and if found,\n"
+ " recovery, tos\n"
" flash <partition> [ <filename> ] write a file to a flash partition\n"
" erase <partition> erase a flash partition\n"
- " format <partition> format a flash partition \n"
+ " format[:[<fs type>][:[<size>]] <partition> format a flash partition.\n"
+ " Can override the fs type and/or\n"
+ " size the bootloader reports.\n"
" getvar <variable> display a bootloader variable\n"
" boot <kernel> [ <ramdisk> ] download and boot kernel\n"
" flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it\n"
@@ -308,10 +316,12 @@
" -p <product> specify product name\n"
" -c <cmdline> override kernel commandline\n"
" -i <vendor id> specify a custom USB vendor id\n"
- " -b <base_addr> specify a custom kernel base address. default: 0x10000000\n"
- " -n <page size> specify the nand page size. default: 2048\n"
- " -S <size>[K|M|G] automatically sparse files greater than\n"
- " size. 0 to disable\n"
+ " -b <base_addr> specify a custom kernel base address.\n"
+ " default: 0x10000000\n"
+ " -n <page size> specify the nand page size.\n"
+ " default: 2048\n"
+ " -S <size>[K|M|G] automatically sparse files greater\n"
+ " than size. 0 to disable\n"
);
}
@@ -612,7 +622,7 @@
/* The function fb_format_supported() currently returns the value
* we want, so just call it.
*/
- return fb_format_supported(usb, part);
+ return fb_format_supported(usb, part, NULL);
}
static int load_buf_fd(usb_handle *usb, int fd,
@@ -622,10 +632,13 @@
void *data;
int64_t limit;
+
sz64 = file_size(fd);
if (sz64 < 0) {
return -1;
}
+
+ lseek(fd, 0, SEEK_SET);
limit = get_sparse_limit(usb, sz64);
if (limit) {
struct sparse_file **s = load_sparse_files(fd, limit);
@@ -653,7 +666,7 @@
fd = open(fname, O_RDONLY | O_BINARY);
if (fd < 0) {
- die("cannot open '%s'\n", fname);
+ return -1;
}
return load_buf_fd(usb, fd, buf);
@@ -872,6 +885,92 @@
return num;
}
+void fb_perform_format(const char *partition, int skip_if_not_supported,
+ const char *type_override, const char *size_override)
+{
+ char pTypeBuff[FB_RESPONSE_SZ + 1], pSizeBuff[FB_RESPONSE_SZ + 1];
+ char *pType = pTypeBuff;
+ char *pSize = pSizeBuff;
+ unsigned int limit = INT_MAX;
+ struct fastboot_buffer buf;
+ const char *errMsg = NULL;
+ const struct fs_generator *gen;
+ uint64_t pSz;
+ int status;
+ int fd;
+
+ if (target_sparse_limit > 0 && target_sparse_limit < limit)
+ limit = target_sparse_limit;
+ if (sparse_limit > 0 && sparse_limit < limit)
+ limit = sparse_limit;
+
+ status = fb_getvar(usb, pType, "partition-type:%s", partition);
+ if (status) {
+ errMsg = "Can't determine partition type.\n";
+ goto failed;
+ }
+ if (type_override) {
+ if (strcmp(type_override, pType)) {
+ fprintf(stderr,
+ "Warning: %s type is %s, but %s was requested for formating.\n",
+ partition, pType, type_override);
+ }
+ pType = type_override;
+ }
+
+ status = fb_getvar(usb, pSize, "partition-size:%s", partition);
+ if (status) {
+ errMsg = "Unable to get partition size\n";
+ goto failed;
+ }
+ if (size_override) {
+ if (strcmp(size_override, pSize)) {
+ fprintf(stderr,
+ "Warning: %s size is %s, but %s was requested for formating.\n",
+ partition, pSize, size_override);
+ }
+ pSize = size_override;
+ }
+
+ gen = fs_get_generator(pType);
+ if (!gen) {
+ if (skip_if_not_supported) {
+ fprintf(stderr, "Erase successful, but not automatically formatting.\n");
+ fprintf(stderr, "File system type %s not supported.\n", pType);
+ return;
+ }
+ fprintf(stderr, "Formatting is not supported for filesystem with type '%s'.\n", pType);
+ return;
+ }
+
+ pSz = strtoll(pSize, (char **)NULL, 16);
+
+ fd = fileno(tmpfile());
+ if (fs_generator_generate(gen, fd, pSz)) {
+ close(fd);
+ fprintf(stderr, "Cannot generate image.\n");
+ return;
+ }
+
+ if (load_buf_fd(usb, fd, &buf)) {
+ fprintf(stderr, "Cannot read image.\n");
+ close(fd);
+ return;
+ }
+ flash_buf(partition, &buf);
+
+ return;
+
+
+failed:
+ if (skip_if_not_supported) {
+ fprintf(stderr, "Erase successful, but not automatically formatting.\n");
+ if (errMsg)
+ fprintf(stderr, "%s", errMsg);
+ }
+ fprintf(stderr,"FAILED (%s)\n", fb_get_error());
+}
+
int main(int argc, char **argv)
{
int wants_wipe = 0;
@@ -993,18 +1092,42 @@
} else if(!strcmp(*argv, "erase")) {
require(2);
- if (fb_format_supported(usb, argv[1])) {
+ if (fb_format_supported(usb, argv[1], NULL)) {
fprintf(stderr, "******** Did you mean to fastboot format this partition?\n");
}
fb_queue_erase(argv[1]);
skip(2);
- } else if(!strcmp(*argv, "format")) {
+ } else if(!strncmp(*argv, "format", strlen("format"))) {
+ char *overrides;
+ char *type_override = NULL;
+ char *size_override = NULL;
require(2);
+ /*
+ * Parsing for: "format[:[type][:[size]]]"
+ * Some valid things:
+ * - select ontly the size, and leave default fs type:
+ * format::0x4000000 userdata
+ * - default fs type and size:
+ * format userdata
+ * format:: userdata
+ */
+ overrides = strchr(*argv, ':');
+ if (overrides) {
+ overrides++;
+ size_override = strchr(overrides, ':');
+ if (size_override) {
+ size_override[0] = '\0';
+ size_override++;
+ }
+ type_override = overrides;
+ }
+ if (type_override && !type_override[0]) type_override = NULL;
+ if (size_override && !size_override[0]) size_override = NULL;
if (erase_first && needs_erase(argv[1])) {
fb_queue_erase(argv[1]);
}
- fb_queue_format(argv[1], 0);
+ fb_perform_format(argv[1], 0, type_override, size_override);
skip(2);
} else if(!strcmp(*argv, "signature")) {
require(2);
@@ -1092,9 +1215,9 @@
if (wants_wipe) {
fb_queue_erase("userdata");
- fb_queue_format("userdata", 1);
+ fb_perform_format("userdata", 1, NULL, NULL);
fb_queue_erase("cache");
- fb_queue_format("cache", 1);
+ fb_perform_format("cache", 1, NULL, NULL);
}
if (wants_reboot) {
fb_queue_reboot();
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
index 976c397..fc5d4f4 100644
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -45,11 +45,11 @@
/* engine.c - high level command queue engine */
int fb_getvar(struct usb_handle *usb, char *response, const char *fmt, ...);
-int fb_format_supported(usb_handle *usb, const char *partition);
+int fb_format_supported(usb_handle *usb, const char *partition, const char *type_override);
void fb_queue_flash(const char *ptn, void *data, unsigned sz);
void fb_queue_flash_sparse(const char *ptn, struct sparse_file *s, unsigned sz);
void fb_queue_erase(const char *ptn);
-void fb_queue_format(const char *ptn, int skip_if_not_supported);
+void fb_queue_format(const char *ptn, int skip_if_not_supported, unsigned int max_chunk_sz);
void fb_queue_require(const char *prod, const char *var, int invert,
unsigned nvalues, const char **value);
void fb_queue_display(const char *var, const char *prettyname);
diff --git a/fastboot/fs.c b/fastboot/fs.c
new file mode 100644
index 0000000..cd4b880
--- /dev/null
+++ b/fastboot/fs.c
@@ -0,0 +1,56 @@
+#include "fastboot.h"
+#include "make_ext4fs.h"
+#include "fs.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sparse/sparse.h>
+#include <unistd.h>
+
+#ifdef USE_MINGW
+#include <fcntl.h>
+#else
+#include <sys/mman.h>
+#endif
+
+
+
+static int generate_ext4_image(int fd, long long partSize)
+{
+ make_ext4fs_sparse_fd(fd, partSize, NULL, NULL);
+
+ return 0;
+}
+
+static const struct fs_generator {
+
+ char *fs_type; //must match what fastboot reports for partition type
+ int (*generate)(int fd, long long partSize); //returns 0 or error value
+
+} generators[] = {
+
+ { "ext4", generate_ext4_image}
+
+};
+
+const struct fs_generator* fs_get_generator(const char *fs_type)
+{
+ unsigned i;
+
+ for (i = 0; i < sizeof(generators) / sizeof(*generators); i++)
+ if (!strcmp(generators[i].fs_type, fs_type))
+ return generators + i;
+
+ return NULL;
+}
+
+int fs_generator_generate(const struct fs_generator* gen, int tmpFileNo, long long partSize)
+{
+ return gen->generate(tmpFileNo, partSize);
+}
diff --git a/fastboot/fs.h b/fastboot/fs.h
new file mode 100644
index 0000000..8388629
--- /dev/null
+++ b/fastboot/fs.h
@@ -0,0 +1,12 @@
+#ifndef _FS_H_
+#define _FH_H_
+
+#include <stdint.h>
+
+struct fs_generator;
+
+const struct fs_generator* fs_get_generator(const char *fs_type);
+int fs_generator_generate(const struct fs_generator* gen, int tmpFileNo, long long partSize);
+
+#endif
+
diff --git a/fastboot/usb_windows.c b/fastboot/usb_windows.c
index 07f7be2..f666015 100644
--- a/fastboot/usb_windows.c
+++ b/fastboot/usb_windows.c
@@ -152,7 +152,7 @@
}
int usb_write(usb_handle* handle, const void* data, int len) {
- unsigned long time_out = 500 + len * 8;
+ unsigned long time_out = 5000;
unsigned long written = 0;
unsigned count = 0;
int ret;
@@ -194,7 +194,7 @@
}
int usb_read(usb_handle *handle, void* data, int len) {
- unsigned long time_out = 500 + len * 8;
+ unsigned long time_out = 0;
unsigned long read = 0;
int ret;
@@ -212,7 +212,7 @@
DBG("usb_read got: %ld, expected: %d, errno: %d\n", read, xfer, errno);
if (ret) {
return read;
- } else if (errno != ERROR_SEM_TIMEOUT) {
+ } else {
// assume ERROR_INVALID_HANDLE indicates we are disconnected
if (errno == ERROR_INVALID_HANDLE)
usb_kick(handle);
diff --git a/fs_mgr/Android.mk b/fs_mgr/Android.mk
index 165ebd4..7cffc37 100644
--- a/fs_mgr/Android.mk
+++ b/fs_mgr/Android.mk
@@ -11,6 +11,7 @@
LOCAL_STATIC_LIBRARIES := liblogwrap libmincrypt libext4_utils_static
LOCAL_C_INCLUDES += system/extras/ext4_utils
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_CFLAGS := -Werror
include $(BUILD_STATIC_LIBRARY)
@@ -31,5 +32,7 @@
LOCAL_STATIC_LIBRARIES := libfs_mgr liblogwrap libcutils liblog libc libmincrypt libext4_utils_static
+LOCAL_CFLAGS := -Werror
+
include $(BUILD_EXECUTABLE)
diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c
index 45bbfdc..f86fc6a 100644
--- a/fs_mgr/fs_mgr_fstab.c
+++ b/fs_mgr/fs_mgr_fstab.c
@@ -162,7 +162,6 @@
p = strtok_r(NULL, ",", &savep);
}
-out:
if (fs_options && fs_options[0]) {
/* remove the last trailing comma from the list of options */
fs_options[strlen(fs_options) - 1] = '\0';
@@ -181,7 +180,6 @@
const char *delim = " \t";
char *save_ptr, *p;
struct fstab *fstab = NULL;
- struct fstab_rec *recs;
struct fs_mgr_flag_values flag_vals;
#define FS_OPTIONS_LEN 1024
char tmp_fs_options[FS_OPTIONS_LEN];
diff --git a/fs_mgr/fs_mgr_verity.c b/fs_mgr/fs_mgr_verity.c
index 40bc2ec..c9a2a9b 100644
--- a/fs_mgr/fs_mgr_verity.c
+++ b/fs_mgr/fs_mgr_verity.c
@@ -85,7 +85,6 @@
static int verify_table(char *signature, char *table, int table_length)
{
- int fd;
RSAPublicKey *key;
uint8_t hash_buf[SHA_DIGEST_SIZE];
int retval = -1;
diff --git a/gpttool/Android.mk b/gpttool/Android.mk
index b8f9844..64ad945 100644
--- a/gpttool/Android.mk
+++ b/gpttool/Android.mk
@@ -5,6 +5,7 @@
LOCAL_SRC_FILES := gpttool.c
LOCAL_STATIC_LIBRARIES := libz
+LOCAL_CFLAGS := -Werror
LOCAL_MODULE := gpttool
diff --git a/gpttool/gpttool.c b/gpttool/gpttool.c
index d3f08fe..398362f 100644
--- a/gpttool/gpttool.c
+++ b/gpttool/gpttool.c
@@ -1,5 +1,4 @@
-/* system/core/gpttool/gpttool.c
-**
+/*
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,18 +14,18 @@
** limitations under the License.
*/
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
-#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <zlib.h>
#include <linux/fs.h>
-#include <sys/stat.h>
-
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
@@ -252,11 +251,9 @@
int main(int argc, char **argv)
{
struct ptable ptbl;
- struct efi_entry *entry;
struct efi_header *hdr = &ptbl.header;
- struct stat s;
u32 n;
- u64 sz, blk;
+ u64 sz;
int fd;
const char *device;
int real_disk = 0;
diff --git a/include/corkscrew/backtrace.h b/include/corkscrew/backtrace.h
deleted file mode 100644
index 556ad04..0000000
--- a/include/corkscrew/backtrace.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* A stack unwinder. */
-
-#ifndef _CORKSCREW_BACKTRACE_H
-#define _CORKSCREW_BACKTRACE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <corkscrew/ptrace.h>
-#include <corkscrew/map_info.h>
-#include <corkscrew/symbol_table.h>
-
-/*
- * Describes a single frame of a backtrace.
- */
-typedef struct {
- uintptr_t absolute_pc; /* absolute PC offset */
- uintptr_t stack_top; /* top of stack for this frame */
- size_t stack_size; /* size of this stack frame */
-} backtrace_frame_t;
-
-/*
- * Describes the symbols associated with a backtrace frame.
- */
-typedef struct {
- uintptr_t relative_pc; /* relative frame PC offset from the start of the library,
- or the absolute PC if the library is unknown */
- uintptr_t relative_symbol_addr; /* relative offset of the symbol from the start of the
- library or 0 if the library is unknown */
- char* map_name; /* executable or library name, or NULL if unknown */
- char* symbol_name; /* symbol name, or NULL if unknown */
- char* demangled_name; /* demangled symbol name, or NULL if unknown */
-} backtrace_symbol_t;
-
-/*
- * Unwinds the call stack for the current thread of execution.
- * Populates the backtrace array with the program counters from the call stack.
- * Returns the number of frames collected, or -1 if an error occurred.
- */
-ssize_t unwind_backtrace(backtrace_frame_t* backtrace, size_t ignore_depth, size_t max_depth);
-
-/*
- * Unwinds the call stack for a thread within this process.
- * Populates the backtrace array with the program counters from the call stack.
- * Returns the number of frames collected, or -1 if an error occurred.
- *
- * The task is briefly suspended while the backtrace is being collected.
- */
-ssize_t unwind_backtrace_thread(pid_t tid, backtrace_frame_t* backtrace,
- size_t ignore_depth, size_t max_depth);
-
-/*
- * Unwinds the call stack of a task within a remote process using ptrace().
- * Populates the backtrace array with the program counters from the call stack.
- * Returns the number of frames collected, or -1 if an error occurred.
- */
-ssize_t unwind_backtrace_ptrace(pid_t tid, const ptrace_context_t* context,
- backtrace_frame_t* backtrace, size_t ignore_depth, size_t max_depth);
-
-/*
- * Gets the symbols for each frame of a backtrace.
- * The symbols array must be big enough to hold one symbol record per frame.
- * The symbols must later be freed using free_backtrace_symbols.
- */
-void get_backtrace_symbols(const backtrace_frame_t* backtrace, size_t frames,
- backtrace_symbol_t* backtrace_symbols);
-
-/*
- * Gets the symbols for each frame of a backtrace from a remote process.
- * The symbols array must be big enough to hold one symbol record per frame.
- * The symbols must later be freed using free_backtrace_symbols.
- */
-void get_backtrace_symbols_ptrace(const ptrace_context_t* context,
- const backtrace_frame_t* backtrace, size_t frames,
- backtrace_symbol_t* backtrace_symbols);
-
-/*
- * Frees the storage associated with backtrace symbols.
- */
-void free_backtrace_symbols(backtrace_symbol_t* backtrace_symbols, size_t frames);
-
-enum {
- // A hint for how big to make the line buffer for format_backtrace_line
- MAX_BACKTRACE_LINE_LENGTH = 800,
-};
-
-/**
- * Formats a line from a backtrace as a zero-terminated string into the specified buffer.
- */
-void format_backtrace_line(unsigned frameNumber, const backtrace_frame_t* frame,
- const backtrace_symbol_t* symbol, char* buffer, size_t bufferSize);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _CORKSCREW_BACKTRACE_H
diff --git a/include/corkscrew/demangle.h b/include/corkscrew/demangle.h
deleted file mode 100644
index 04b0225..0000000
--- a/include/corkscrew/demangle.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* C++ symbol name demangling. */
-
-#ifndef _CORKSCREW_DEMANGLE_H
-#define _CORKSCREW_DEMANGLE_H
-
-#include <sys/types.h>
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Demangles a C++ symbol name.
- * If name is NULL or if the name cannot be demangled, returns NULL.
- * Otherwise, returns a newly allocated string that contains the demangled name.
- *
- * The caller must free the returned string using free().
- */
-char* demangle_symbol_name(const char* name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _CORKSCREW_DEMANGLE_H
diff --git a/include/corkscrew/map_info.h b/include/corkscrew/map_info.h
deleted file mode 100644
index 14bfad6..0000000
--- a/include/corkscrew/map_info.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Process memory map. */
-
-#ifndef _CORKSCREW_MAP_INFO_H
-#define _CORKSCREW_MAP_INFO_H
-
-#include <sys/types.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct map_info {
- struct map_info* next;
- uintptr_t start;
- uintptr_t end;
- bool is_readable;
- bool is_writable;
- bool is_executable;
- void* data; // arbitrary data associated with the map by the user, initially NULL
- char name[];
-} map_info_t;
-
-/* Loads memory map from /proc/<tid>/maps. */
-map_info_t* load_map_info_list(pid_t tid);
-
-/* Frees memory map. */
-void free_map_info_list(map_info_t* milist);
-
-/* Finds the memory map that contains the specified address. */
-const map_info_t* find_map_info(const map_info_t* milist, uintptr_t addr);
-
-/* Returns true if the addr is in a readable map. */
-bool is_readable_map(const map_info_t* milist, uintptr_t addr);
-/* Returns true if the addr is in a writable map. */
-bool is_writable_map(const map_info_t* milist, uintptr_t addr);
-/* Returns true if the addr is in an executable map. */
-bool is_executable_map(const map_info_t* milist, uintptr_t addr);
-
-/* Acquires a reference to the memory map for this process.
- * The result is cached and refreshed automatically.
- * Make sure to release the map info when done. */
-map_info_t* acquire_my_map_info_list();
-
-/* Releases a reference to the map info for this process that was
- * previous acquired using acquire_my_map_info_list(). */
-void release_my_map_info_list(map_info_t* milist);
-
-/* Flushes the cached memory map so the next call to
- * acquire_my_map_info_list() gets fresh data. */
-void flush_my_map_info_list();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _CORKSCREW_MAP_INFO_H
diff --git a/include/corkscrew/ptrace.h b/include/corkscrew/ptrace.h
deleted file mode 100644
index 76276d8..0000000
--- a/include/corkscrew/ptrace.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Useful ptrace() utility functions. */
-
-#ifndef _CORKSCREW_PTRACE_H
-#define _CORKSCREW_PTRACE_H
-
-#include <corkscrew/map_info.h>
-#include <corkscrew/symbol_table.h>
-
-#include <sys/types.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Stores information about a process that is used for several different
- * ptrace() based operations. */
-typedef struct {
- map_info_t* map_info_list;
-} ptrace_context_t;
-
-/* Describes how to access memory from a process. */
-typedef struct {
- pid_t tid;
- const map_info_t* map_info_list;
-} memory_t;
-
-#if __i386__
-/* ptrace() register context. */
-typedef struct pt_regs_x86 {
- uint32_t ebx;
- uint32_t ecx;
- uint32_t edx;
- uint32_t esi;
- uint32_t edi;
- uint32_t ebp;
- uint32_t eax;
- uint32_t xds;
- uint32_t xes;
- uint32_t xfs;
- uint32_t xgs;
- uint32_t orig_eax;
- uint32_t eip;
- uint32_t xcs;
- uint32_t eflags;
- uint32_t esp;
- uint32_t xss;
-} pt_regs_x86_t;
-#endif
-
-#if __mips__
-/* ptrace() GET_REGS context. */
-typedef struct pt_regs_mips {
- uint64_t regs[32];
- uint64_t lo;
- uint64_t hi;
- uint64_t cp0_epc;
- uint64_t cp0_badvaddr;
- uint64_t cp0_status;
- uint64_t cp0_cause;
-} pt_regs_mips_t;
-#endif
-
-/*
- * Initializes a memory structure for accessing memory from this process.
- */
-void init_memory(memory_t* memory, const map_info_t* map_info_list);
-
-/*
- * Initializes a memory structure for accessing memory from another process
- * using ptrace().
- */
-void init_memory_ptrace(memory_t* memory, pid_t tid);
-
-/*
- * Reads a word of memory safely.
- * If the memory is local, ensures that the address is readable before dereferencing it.
- * Returns false and a value of 0xffffffff if the word could not be read.
- */
-bool try_get_word(const memory_t* memory, uintptr_t ptr, uint32_t* out_value);
-
-/*
- * Reads a word of memory safely using ptrace().
- * Returns false and a value of 0xffffffff if the word could not be read.
- */
-bool try_get_word_ptrace(pid_t tid, uintptr_t ptr, uint32_t* out_value);
-
-/*
- * Loads information needed for examining a remote process using ptrace().
- * The caller must already have successfully attached to the process
- * using ptrace().
- *
- * The context can be used for any threads belonging to that process
- * assuming ptrace() is attached to them before performing the actual
- * unwinding. The context can continue to be used to decode backtraces
- * even after ptrace() has been detached from the process.
- */
-ptrace_context_t* load_ptrace_context(pid_t pid);
-
-/*
- * Frees a ptrace context.
- */
-void free_ptrace_context(ptrace_context_t* context);
-
-/*
- * Finds a symbol using ptrace.
- * Returns the containing map and information about the symbol, or
- * NULL if one or the other is not available.
- */
-void find_symbol_ptrace(const ptrace_context_t* context,
- uintptr_t addr, const map_info_t** out_map_info, const symbol_t** out_symbol);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _CORKSCREW_PTRACE_H
diff --git a/include/corkscrew/symbol_table.h b/include/corkscrew/symbol_table.h
deleted file mode 100644
index 4998750..0000000
--- a/include/corkscrew/symbol_table.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _CORKSCREW_SYMBOL_TABLE_H
-#define _CORKSCREW_SYMBOL_TABLE_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- uintptr_t start;
- uintptr_t end;
- char* name;
-} symbol_t;
-
-typedef struct {
- symbol_t* symbols;
- size_t num_symbols;
-} symbol_table_t;
-
-/*
- * Loads a symbol table from a given file.
- * Returns NULL on error.
- */
-symbol_table_t* load_symbol_table(const char* filename);
-
-/*
- * Frees a symbol table.
- */
-void free_symbol_table(symbol_table_t* table);
-
-/*
- * Finds a symbol associated with an address in the symbol table.
- * Returns NULL if not found.
- */
-const symbol_t* find_symbol(const symbol_table_t* table, uintptr_t addr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _CORKSCREW_SYMBOL_TABLE_H
diff --git a/libbacktrace/Android.mk b/libbacktrace/Android.mk
index 9c1b011..fa79221 100755
--- a/libbacktrace/Android.mk
+++ b/libbacktrace/Android.mk
@@ -105,10 +105,8 @@
GetPss.cpp \
thread_utils.c \
-backtrace_test_ldlibs := \
- -lpthread \
-
backtrace_test_ldlibs_host := \
+ -lpthread \
-lrt \
backtrace_test_shared_libraries := \
diff --git a/libcutils/Android.mk b/libcutils/Android.mk
index 2dcc965..945ebdd 100644
--- a/libcutils/Android.mk
+++ b/libcutils/Android.mk
@@ -75,7 +75,6 @@
# ========================================================
LOCAL_MODULE := libcutils
LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c
-LOCAL_LDLIBS := -lpthread
LOCAL_STATIC_LIBRARIES := liblog
LOCAL_CFLAGS += $(hostSmpFlag)
ifneq ($(HOST_OS),windows)
@@ -89,7 +88,6 @@
include $(CLEAR_VARS)
LOCAL_MODULE := lib64cutils
LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c
-LOCAL_LDLIBS := -lpthread
LOCAL_STATIC_LIBRARIES := lib64log
LOCAL_CFLAGS += $(hostSmpFlag) -m64
ifneq ($(HOST_OS),windows)
diff --git a/libdiskconfig/diskutils.c b/libdiskconfig/diskutils.c
index 7659632..5d0ee62 100644
--- a/libdiskconfig/diskutils.c
+++ b/libdiskconfig/diskutils.c
@@ -41,7 +41,7 @@
int done = 0;
uint64_t total = 0;
- ALOGI("Writing RAW image '%s' to '%s' (offset=%llu)", src, dst, offset);
+ ALOGI("Writing RAW image '%s' to '%s' (offset=%llu)", src, dst, (unsigned long long)offset);
if ((src_fd = open(src, O_RDONLY)) < 0) {
ALOGE("Could not open %s for reading (errno=%d).", src, errno);
goto fail;
@@ -54,7 +54,7 @@
}
if (lseek64(dst_fd, offset, SEEK_SET) != offset) {
- ALOGE("Could not seek to offset %lld in %s.", offset, dst);
+ ALOGE("Could not seek to offset %lld in %s.", (long long)offset, dst);
goto fail;
}
}
@@ -102,7 +102,7 @@
if (dst_fd >= 0)
fsync(dst_fd);
- ALOGI("Wrote %" PRIu64 " bytes to %s @ %lld", total, dst, offset);
+ ALOGI("Wrote %" PRIu64 " bytes to %s @ %lld", total, dst, (long long)offset);
close(src_fd);
if (dst_fd >= 0)
diff --git a/libdiskconfig/write_lst.c b/libdiskconfig/write_lst.c
index 826ef7a..90b1c82 100644
--- a/libdiskconfig/write_lst.c
+++ b/libdiskconfig/write_lst.c
@@ -71,18 +71,18 @@
{
for(; lst; lst = lst->next) {
if (lseek64(fd, lst->offset, SEEK_SET) != (loff_t)lst->offset) {
- ALOGE("Cannot seek to the specified position (%lld).", lst->offset);
+ ALOGE("Cannot seek to the specified position (%lld).", (long long)lst->offset);
goto fail;
}
if (!test) {
if (write(fd, lst->data, lst->len) != (int)lst->len) {
ALOGE("Failed writing %u bytes at position %lld.", lst->len,
- lst->offset);
+ (long long)lst->offset);
goto fail;
}
} else
- ALOGI("Would write %d bytes @ offset %lld.", lst->len, lst->offset);
+ ALOGI("Would write %d bytes @ offset %lld.", lst->len, (long long)lst->offset);
}
return 0;
diff --git a/liblog/Android.mk b/liblog/Android.mk
index 5e01903..69ca416 100644
--- a/liblog/Android.mk
+++ b/liblog/Android.mk
@@ -57,11 +57,7 @@
# ========================================================
LOCAL_MODULE := liblog
LOCAL_SRC_FILES := $(liblog_host_sources)
-LOCAL_LDLIBS := -lpthread
-ifeq ($(strip $(HOST_OS)),linux)
-LOCAL_LDLIBS += -lrt
-endif
-LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1
+LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1 -Werror
include $(BUILD_HOST_STATIC_LIBRARY)
include $(CLEAR_VARS)
@@ -78,11 +74,7 @@
include $(CLEAR_VARS)
LOCAL_MODULE := lib64log
LOCAL_SRC_FILES := $(liblog_host_sources)
-LOCAL_LDLIBS := -lpthread
-ifeq ($(strip $(HOST_OS)),linux)
-LOCAL_LDLIBS += -lrt
-endif
-LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1 -m64
+LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1 -m64 -Werror
include $(BUILD_HOST_STATIC_LIBRARY)
# Shared and static library for target
@@ -90,13 +82,13 @@
include $(CLEAR_VARS)
LOCAL_MODULE := liblog
LOCAL_SRC_FILES := $(liblog_target_sources)
-LOCAL_CFLAGS := $(liblog_cflags)
+LOCAL_CFLAGS := -Werror
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblog
LOCAL_WHOLE_STATIC_LIBRARIES := liblog
-LOCAL_CFLAGS := $(liblog_cflags)
+LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)
include $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/liblog/event_tag_map.c b/liblog/event_tag_map.c
index f3d1e2f..bea99aa 100644
--- a/liblog/event_tag_map.c
+++ b/liblog/event_tag_map.c
@@ -13,15 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <log/event_tag_map.h>
-#include <log/log.h>
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
-#include <fcntl.h>
#include <sys/mman.h>
-#include <errno.h>
-#include <assert.h>
+
+#include <log/event_tag_map.h>
+#include <log/log.h>
#define OUT_TAG "EventTagMap"
@@ -52,7 +53,6 @@
static int parseMapLines(EventTagMap* map);
static int scanTagLine(char** pData, EventTag* tag, int lineNum);
static int sortTags(EventTagMap* map);
-static void dumpTags(const EventTagMap* map);
/*
@@ -185,8 +185,6 @@
*/
static int processFile(EventTagMap* map)
{
- EventTag* tagArray = NULL;
-
/* get a tag count */
map->numTags = countMapLines(map);
if (map->numTags < 0)
@@ -422,17 +420,3 @@
return 0;
}
-
-/*
- * Dump the tag array for debugging.
- */
-static void dumpTags(const EventTagMap* map)
-{
- int i;
-
- for (i = 0; i < map->numTags; i++) {
- const EventTag* tag = &map->tagArray[i];
- printf(" %3d: %6d '%s'\n", i, tag->tagIndex, tag->tagStr);
- }
-}
-
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index da83a85..136792d 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -21,18 +21,22 @@
*/
#include "fake_log_device.h"
-#include <log/logd.h>
-
-#include <stdlib.h>
-#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <log/logd.h>
#ifdef HAVE_PTHREADS
#include <pthread.h>
#endif
+#ifndef __unused
+#define __unused __attribute__((__unused__))
+#endif
+
#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */
#define kTagSetSize 16 /* arbitrary */
@@ -613,7 +617,7 @@
/*
* Open a log output device and return a fake fd.
*/
-static int logOpen(const char* pathName, int flags)
+static int logOpen(const char* pathName, int flags __unused)
{
LogState *logState;
int fd = -1;
diff --git a/liblog/log_read.c b/liblog/log_read.c
index 11fe848..ca5a1a7 100644
--- a/liblog/log_read.c
+++ b/liblog/log_read.c
@@ -23,6 +23,7 @@
#define NOMINMAX /* for windows to suppress definition of min in stdlib.h */
#include <stdlib.h>
#include <string.h>
+#include <sys/cdefs.h>
#include <unistd.h>
#include <cutils/list.h>
@@ -34,7 +35,9 @@
#define min(x,y) ((y) ^ (((x) ^ (y)) & -((x) < (y))))
#define WEAK __attribute__((weak))
-#define UNUSED __attribute__((unused))
+#ifndef __unused
+#define __unused __attribute__((unused))
+#endif
/* Private copy of ../libcutils/socket_local_client.c prevent library loops */
@@ -142,11 +145,10 @@
* Used by AndroidSocketImpl
*/
int WEAK socket_local_client_connect(int fd, const char *name, int namespaceId,
- int type UNUSED)
+ int type __unused)
{
struct sockaddr_un addr;
socklen_t alen;
- size_t namelen;
int err;
err = socket_make_sockaddr_un(name, namespaceId, &addr, &alen);
@@ -409,7 +411,7 @@
/*
* returns the logger version
*/
-int android_logger_get_log_version(struct logger *logger UNUSED)
+int android_logger_get_log_version(struct logger *logger __unused)
{
return 3;
}
@@ -420,7 +422,6 @@
ssize_t android_logger_get_statistics(struct logger_list *logger_list,
char *buf, size_t len)
{
- struct listnode *node;
struct logger *logger;
char *cp = buf;
size_t remaining = len;
@@ -440,13 +441,13 @@
return send_log_msg(NULL, NULL, buf, len);
}
-ssize_t android_logger_get_prune_list(struct logger_list *logger_list UNUSED,
+ssize_t android_logger_get_prune_list(struct logger_list *logger_list __unused,
char *buf, size_t len)
{
return send_log_msg(NULL, "getPruneList", buf, len);
}
-int android_logger_set_prune_list(struct logger_list *logger_list UNUSED,
+int android_logger_set_prune_list(struct logger_list *logger_list __unused,
char *buf, size_t len)
{
const char cmd[] = "setPruneList ";
@@ -512,9 +513,7 @@
struct logger *android_logger_open(struct logger_list *logger_list,
log_id_t id)
{
- struct listnode *node;
struct logger *logger;
- char *n;
if (!logger_list || (id >= LOG_ID_MAX)) {
goto err;
@@ -561,7 +560,7 @@
return logger_list;
}
-static void caught_signal(int signum UNUSED)
+static void caught_signal(int signum __unused)
{
}
diff --git a/liblog/log_read_kern.c b/liblog/log_read_kern.c
index 021fe47..41b8a51 100644
--- a/liblog/log_read_kern.c
+++ b/liblog/log_read_kern.c
@@ -21,12 +21,13 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/cdefs.h>
+#include <sys/ioctl.h>
+
#include <cutils/list.h>
#include <log/log.h>
#include <log/logger.h>
-#include <sys/ioctl.h>
-
#define __LOGGERIO 0xAE
#define LOGGER_GET_LOG_BUF_SIZE _IO(__LOGGERIO, 1) /* size of log */
@@ -51,7 +52,9 @@
logger != node_to_item(&(logger_list)->node, struct logger, node); \
logger = node_to_item((logger)->node.next, struct logger, node))
-#define UNUSED __attribute__((unused))
+#ifndef __unused
+#define __unused __attribute__((unused))
+#endif
/* In the future, we would like to make this list extensible */
static const char *LOG_NAME[LOG_ID_MAX] = {
@@ -233,8 +236,8 @@
return logger_ioctl(logger, LOGGER_GET_LOG_BUF_SIZE, O_RDWR);
}
-int android_logger_set_log_size(struct logger *logger UNUSED,
- unsigned long size UNUSED)
+int android_logger_set_log_size(struct logger *logger __unused,
+ unsigned long size __unused)
{
return -ENOTSUP;
}
@@ -262,21 +265,21 @@
*/
static const char unsupported[] = "18\nNot Supported\n\f";
-ssize_t android_logger_get_statistics(struct logger_list *logger_list UNUSED,
+ssize_t android_logger_get_statistics(struct logger_list *logger_list __unused,
char *buf, size_t len)
{
strncpy(buf, unsupported, len);
return -ENOTSUP;
}
-ssize_t android_logger_get_prune_list(struct logger_list *logger_list UNUSED,
+ssize_t android_logger_get_prune_list(struct logger_list *logger_list __unused,
char *buf, size_t len)
{
strncpy(buf, unsupported, len);
return -ENOTSUP;
}
-int android_logger_set_prune_list(struct logger_list *logger_list UNUSED,
+int android_logger_set_prune_list(struct logger_list *logger_list __unused,
char *buf, size_t len)
{
static const char unsupported_error[] = "Unsupported";
@@ -302,7 +305,7 @@
}
struct logger_list *android_logger_list_alloc_time(int mode,
- log_time start UNUSED,
+ log_time start __unused,
pid_t pid)
{
return android_logger_list_alloc(mode, 0, pid);
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index bd36a65..121d84d 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -49,12 +49,15 @@
static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
-#define UNUSED __attribute__((__unused__))
+#ifndef __unused
+#define __unused __attribute__((__unused__))
+#endif
-static int logd_fd = -1;
#if FAKE_LOG_DEVICE
#define WEAK __attribute__((weak))
static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1, -1 };
+#else
+static int logd_fd = -1;
#endif
/*
@@ -77,12 +80,14 @@
return (g_log_status == kLogAvailable);
}
+#if !FAKE_LOG_DEVICE
/* give up, resources too limited */
-static int __write_to_log_null(log_id_t log_fd UNUSED, struct iovec *vec UNUSED,
- size_t nr UNUSED)
+static int __write_to_log_null(log_id_t log_fd __unused, struct iovec *vec __unused,
+ size_t nr __unused)
{
return -1;
}
+#endif
/* log_init_lock assumed */
static int __write_to_log_initialize()
@@ -323,6 +328,13 @@
tag = tmp_tag;
}
+#if __BIONIC__
+ if (prio == ANDROID_LOG_FATAL) {
+ extern void __android_set_abort_message(const char*);
+ __android_set_abort_message(msg);
+ }
+#endif
+
vec[0].iov_base = (unsigned char *) &prio;
vec[0].iov_len = 1;
vec[1].iov_base = (void *) tag;
@@ -422,14 +434,8 @@
strcpy(buf, "Unspecified assertion failed");
}
-#if __BIONIC__
- // Ensure debuggerd gets to see what went wrong by keeping the C library in the loop.
- extern __noreturn void __android_fatal(const char* tag, const char* format, ...) __printflike(2, 3);
- __android_fatal(tag ? tag : "", "%s", buf);
-#else
__android_log_write(ANDROID_LOG_FATAL, tag, buf);
__builtin_trap(); /* trap so we have a chance to debug the situation */
-#endif
/* NOTREACHED */
}
diff --git a/liblog/logd_write_kern.c b/liblog/logd_write_kern.c
index 8c707ad..1d10748 100644
--- a/liblog/logd_write_kern.c
+++ b/liblog/logd_write_kern.c
@@ -57,7 +57,9 @@
static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
-#define UNUSED __attribute__((__unused__))
+#ifndef __unused
+#define __unused __attribute__((__unused__))
+#endif
static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1 };
@@ -81,8 +83,8 @@
return (g_log_status == kLogAvailable);
}
-static int __write_to_log_null(log_id_t log_fd UNUSED, struct iovec *vec UNUSED,
- size_t nr UNUSED)
+static int __write_to_log_null(log_id_t log_fd __unused, struct iovec *vec __unused,
+ size_t nr __unused)
{
return -1;
}
@@ -173,6 +175,13 @@
tag = tmp_tag;
}
+#if __BIONIC__
+ if (prio == ANDROID_LOG_FATAL) {
+ extern void __android_set_abort_message(const char*);
+ __android_set_abort_message(msg);
+ }
+#endif
+
vec[0].iov_base = (unsigned char *) &prio;
vec[0].iov_len = 1;
vec[1].iov_base = (void *) tag;
@@ -272,14 +281,8 @@
strcpy(buf, "Unspecified assertion failed");
}
-#if __BIONIC__
- // Ensure debuggerd gets to see what went wrong by keeping the C library in the loop.
- extern __noreturn void __android_fatal(const char* tag, const char* format, ...) __printflike(2, 3);
- __android_fatal(tag ? tag : "", "%s", buf);
-#else
__android_log_write(ANDROID_LOG_FATAL, tag, buf);
__builtin_trap(); /* trap so we have a chance to debug the situation */
-#endif
/* NOTREACHED */
}
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 3bc9f5a..08e830a 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -17,14 +17,14 @@
#define _GNU_SOURCE /* for asprintf */
-#include <ctype.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <assert.h>
#include <arpa/inet.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <log/logd.h>
#include <log/logprint.h>
@@ -52,15 +52,7 @@
return p_ret;
}
-static void filterinfo_free(FilterInfo *p_info)
-{
- if (p_info == NULL) {
- return;
- }
-
- free(p_info->mTag);
- p_info->mTag = NULL;
-}
+/* balance to above, filterinfo_free left unimplemented */
/*
* Note: also accepts 0-9 priorities
@@ -139,23 +131,6 @@
return p_format->global_pri;
}
-/** for debugging */
-static void dumpFilters(AndroidLogFormat *p_format)
-{
- FilterInfo *p_fi;
-
- for (p_fi = p_format->filters ; p_fi != NULL ; p_fi = p_fi->p_next) {
- char cPri = filterPriToChar(p_fi->mPri);
- if (p_fi->mPri == ANDROID_LOG_DEFAULT) {
- cPri = filterPriToChar(p_format->global_pri);
- }
- fprintf(stderr,"%s:%c\n", p_fi->mTag, cPri);
- }
-
- fprintf(stderr,"*:%c\n", filterPriToChar(p_format->global_pri));
-
-}
-
/**
* returns 1 if this log line should be printed based on its priority
* and tag, and 0 if it should not
@@ -234,7 +209,6 @@
int android_log_addFilterRule(AndroidLogFormat *p_format,
const char *filterExpression)
{
- size_t i=0;
size_t tagNameLength;
android_LogPriority pri = ANDROID_LOG_DEFAULT;
@@ -718,7 +692,6 @@
#endif
struct tm* ptm;
char timeBuf[32];
- char headerBuf[128];
char prefixBuf[128], suffixBuf[128];
char priChar;
int prefixSuffixIsHeaderFooter = 0;
@@ -817,7 +790,6 @@
/* the following code is tragically unreadable */
size_t numLines;
- size_t i;
char *p;
size_t bufferSize;
const char *pm;
diff --git a/liblog/tests/Android.mk b/liblog/tests/Android.mk
index d1d9115..255dc2e 100644
--- a/liblog/tests/Android.mk
+++ b/liblog/tests/Android.mk
@@ -83,7 +83,6 @@
LOCAL_MODULE_TAGS := $(test_tags)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += $(test_c_flags)
-LOCAL_LDLIBS := -lpthread
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_SRC_FILES := $(test_src_files)
include $(BUILD_NATIVE_TEST)
diff --git a/liblog/tests/liblog_benchmark.cpp b/liblog/tests/liblog_benchmark.cpp
index 39fe2ad..549d79e 100644
--- a/liblog/tests/liblog_benchmark.cpp
+++ b/liblog/tests/liblog_benchmark.cpp
@@ -99,7 +99,7 @@
}
BENCHMARK(BM_log_overhead);
-static void caught_latency(int signum)
+static void caught_latency(int /*signum*/)
{
unsigned long long v = 0xDEADBEEFA55A5AA5ULL;
@@ -193,7 +193,7 @@
}
BENCHMARK(BM_log_latency);
-static void caught_delay(int signum)
+static void caught_delay(int /*signum*/)
{
unsigned long long v = 0xDEADBEEFA55A5AA6ULL;
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index c6f981f..ec35e45 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -164,7 +164,7 @@
static unsigned signaled;
log_time signal_time;
-static void caught_blocking(int signum)
+static void caught_blocking(int /*signum*/)
{
unsigned long long v = 0xDEADBEEFA55A0000ULL;
diff --git a/libmincrypt/dsa_sig.c b/libmincrypt/dsa_sig.c
index 8df6cf7..101314b 100644
--- a/libmincrypt/dsa_sig.c
+++ b/libmincrypt/dsa_sig.c
@@ -26,6 +26,7 @@
#include <string.h>
+#include "mincrypt/dsa_sig.h"
#include "mincrypt/p256.h"
/**
diff --git a/libmincrypt/test/ecdsa_test.c b/libmincrypt/test/ecdsa_test.c
index b5a7b3a..24ec013 100644
--- a/libmincrypt/test/ecdsa_test.c
+++ b/libmincrypt/test/ecdsa_test.c
@@ -24,15 +24,21 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
#include <ctype.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/cdefs.h>
+#include "mincrypt/dsa_sig.h"
#include "mincrypt/p256.h"
#include "mincrypt/p256_ecdsa.h"
#include "mincrypt/sha256.h"
+#ifndef __unused
+#define __unused __attribute__((__unused__))
+#endif
+
/**
* Messages signed using:
*
@@ -209,7 +215,7 @@
return result;
}
-int main(int arg, char** argv) {
+int main(int arg __unused, char** argv __unused) {
unsigned char hash_buf[SHA256_DIGEST_SIZE];
diff --git a/libmincrypt/test/rsa_test.c b/libmincrypt/test/rsa_test.c
index 17862dc..055138f 100644
--- a/libmincrypt/test/rsa_test.c
+++ b/libmincrypt/test/rsa_test.c
@@ -1,5 +1,4 @@
-/* rsa_test.c
-**
+/*
** Copyright 2013, The Android Open Source Project
**
** Redistribution and use in source and binary forms, with or without
@@ -25,14 +24,19 @@
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
#include <ctype.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/cdefs.h>
#include "mincrypt/rsa.h"
#include "mincrypt/sha.h"
+#ifndef __unused
+#define __unused __attribute__((unused))
+#endif
+
// RSA test data taken from:
//
// ftp://ftp.rsa.com/pub/rsalabs/tmp/pkcs1v15sign-vectors.txt
@@ -791,7 +795,7 @@
}
-int main(int arg, char** argv) {
+int main(int arg __unused, char** argv __unused) {
unsigned char hash[SHA_DIGEST_SIZE];
diff --git a/libsparse/Android.mk b/libsparse/Android.mk
index 9025cc0..02ab412 100644
--- a/libsparse/Android.mk
+++ b/libsparse/Android.mk
@@ -17,6 +17,7 @@
LOCAL_MODULE := libsparse_host
LOCAL_STATIC_LIBRARIES := libz
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include external/zlib
+LOCAL_CFLAGS := -Werror
include $(BUILD_HOST_STATIC_LIBRARY)
@@ -27,6 +28,7 @@
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include external/zlib
LOCAL_SHARED_LIBRARIES := \
libz
+LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)
@@ -36,6 +38,7 @@
LOCAL_MODULE := libsparse_static
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include external/zlib
LOCAL_STATIC_LIBRARIES := libz
+LOCAL_CFLAGS := -Werror
include $(BUILD_STATIC_LIBRARY)
@@ -48,6 +51,7 @@
LOCAL_STATIC_LIBRARIES := \
libsparse_host \
libz
+LOCAL_CFLAGS := -Werror
include $(BUILD_HOST_EXECUTABLE)
@@ -58,6 +62,7 @@
LOCAL_STATIC_LIBRARIES := \
libsparse_static \
libz
+LOCAL_CFLAGS := -Werror
include $(BUILD_EXECUTABLE)
@@ -69,6 +74,7 @@
LOCAL_STATIC_LIBRARIES := \
libsparse_host \
libz
+LOCAL_CFLAGS := -Werror
include $(BUILD_HOST_EXECUTABLE)
@@ -78,6 +84,7 @@
LOCAL_STATIC_LIBRARIES := \
libsparse_static \
libz
+LOCAL_CFLAGS := -Werror
include $(BUILD_EXECUTABLE)
@@ -87,6 +94,7 @@
LOCAL_STATIC_LIBRARIES := \
libsparse_host \
libz
+LOCAL_CFLAGS := -Werror
include $(BUILD_HOST_EXECUTABLE)
@@ -95,5 +103,5 @@
LOCAL_SRC_FILES := simg_dump.py
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_IS_HOST_MODULE := true
+LOCAL_CFLAGS := -Werror
include $(BUILD_PREBUILT)
-
diff --git a/libsparse/img2simg.c b/libsparse/img2simg.c
index 6b1caa5..a0db36f 100644
--- a/libsparse/img2simg.c
+++ b/libsparse/img2simg.c
@@ -47,7 +47,6 @@
{
int in;
int out;
- unsigned int i;
int ret;
struct sparse_file *s;
unsigned int block_size = 4096;
diff --git a/libsparse/output_file.c b/libsparse/output_file.c
index 1cf8d8d..cd30800 100644
--- a/libsparse/output_file.c
+++ b/libsparse/output_file.c
@@ -31,8 +31,8 @@
#include "defs.h"
#include "output_file.h"
-#include "sparse_format.h"
#include "sparse_crc32.h"
+#include "sparse_format.h"
#ifndef USE_MINGW
#include <sys/mman.h>
@@ -295,7 +295,6 @@
static int callback_file_write(struct output_file *out, void *data, int len)
{
- int ret;
struct output_file_callback *outc = to_output_file_callback(out);
return outc->write(outc->priv, data, len);
@@ -341,7 +340,7 @@
static int write_sparse_skip_chunk(struct output_file *out, int64_t skip_len)
{
chunk_header_t chunk_header;
- int ret, chunk;
+ int ret;
if (skip_len % out->block_size) {
error("don't care size %"PRIi64" is not a multiple of the block size %u",
@@ -368,9 +367,8 @@
uint32_t fill_val)
{
chunk_header_t chunk_header;
- int rnd_up_len, zero_len, count;
+ int rnd_up_len, count;
int ret;
- unsigned int i;
/* Round up the fill length to a multiple of the block size */
rnd_up_len = ALIGN(len, out->block_size);
@@ -536,8 +534,6 @@
void output_file_close(struct output_file *out)
{
- int ret;
-
out->sparse_ops->write_end_chunk(out);
out->ops->close(out);
}
diff --git a/libsparse/sparse.c b/libsparse/sparse.c
index 0f107b0..baa30cd 100644
--- a/libsparse/sparse.c
+++ b/libsparse/sparse.c
@@ -279,7 +279,6 @@
struct sparse_file **out_s, int out_s_count)
{
struct backed_block *bb;
- unsigned int overhead;
struct sparse_file *s;
struct sparse_file *tmp;
int c = 0;
diff --git a/libsparse/sparse_read.c b/libsparse/sparse_read.c
index 873c87c..8e188e9 100644
--- a/libsparse/sparse_read.c
+++ b/libsparse/sparse_read.c
@@ -180,22 +180,16 @@
int fd __unused, unsigned int blocks,
unsigned int block __unused, uint32_t *crc32)
{
- int ret;
- int chunk;
- int64_t len = (int64_t)blocks * s->block_size;
- uint32_t fill_val;
- uint32_t *fillbuf;
- unsigned int i;
-
if (chunk_size != 0) {
return -EINVAL;
}
if (crc32) {
+ int64_t len = (int64_t)blocks * s->block_size;
memset(copybuf, 0, COPY_BUF_SIZE);
while (len) {
- chunk = min(len, COPY_BUF_SIZE);
+ int chunk = min(len, COPY_BUF_SIZE);
*crc32 = sparse_crc32(*crc32, copybuf, chunk);
len -= chunk;
}
@@ -367,7 +361,6 @@
int64_t remain = s->len;
int64_t offset = 0;
unsigned int to_read;
- char *ptr;
unsigned int i;
bool sparse_block;
diff --git a/libutils/Android.mk b/libutils/Android.mk
index 1710d36..1c48619 100644
--- a/libutils/Android.mk
+++ b/libutils/Android.mk
@@ -69,7 +69,6 @@
LOCAL_MODULE:= libutils
LOCAL_STATIC_LIBRARIES := liblog
LOCAL_CFLAGS += $(host_commonCflags)
-LOCAL_LDLIBS += $(host_commonLdlibs)
include $(BUILD_HOST_STATIC_LIBRARY)
@@ -83,7 +82,6 @@
LOCAL_MODULE:= lib64utils
LOCAL_STATIC_LIBRARIES := liblog
LOCAL_CFLAGS += $(host_commonCflags) -m64
-LOCAL_LDLIBS += $(host_commonLdlibs)
include $(BUILD_HOST_STATIC_LIBRARY)
@@ -98,10 +96,6 @@
Looper.cpp \
Trace.cpp
-ifeq ($(TARGET_OS),linux)
-LOCAL_LDLIBS += -lrt -ldl
-endif
-
ifeq ($(TARGET_ARCH),mips)
LOCAL_CFLAGS += -DALIGN_DOUBLE
endif
@@ -110,8 +104,6 @@
bionic/libc/private \
external/zlib
-LOCAL_LDLIBS += -lpthread
-
LOCAL_STATIC_LIBRARIES := \
libcutils
diff --git a/libziparchive/Android.mk b/libziparchive/Android.mk
index e754c3b..1d48fea 100644
--- a/libziparchive/Android.mk
+++ b/libziparchive/Android.mk
@@ -30,6 +30,7 @@
LOCAL_MODULE:= libziparchive
LOCAL_C_INCLUDES += ${includes}
+LOCAL_CFLAGS := -Werror
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
@@ -40,6 +41,7 @@
LOCAL_STATIC_LIBRARIES := libz libutils
LOCAL_MODULE:= libziparchive-host
+LOCAL_CFLAGS := -Werror
include $(BUILD_HOST_STATIC_LIBRARY)
include $(CLEAR_VARS)
@@ -47,7 +49,8 @@
LOCAL_CPP_EXTENSION := .cc
LOCAL_CFLAGS += \
-DGTEST_OS_LINUX_ANDROID \
- -DGTEST_HAS_STD_STRING
+ -DGTEST_HAS_STD_STRING \
+ -Werror
LOCAL_SRC_FILES := zip_archive_test.cc
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_STATIC_LIBRARIES := libziparchive libz libgtest libgtest_main libutils
@@ -58,7 +61,8 @@
LOCAL_CPP_EXTENSION := .cc
LOCAL_CFLAGS += \
-DGTEST_OS_LINUX \
- -DGTEST_HAS_STD_STRING
+ -DGTEST_HAS_STD_STRING \
+ -Werror
LOCAL_SRC_FILES := zip_archive_test.cc
LOCAL_STATIC_LIBRARIES := libziparchive-host \
libz \
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index aebddc8..6781ebe 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <utils/Compat.h>
#include <utils/FileMap.h>
#include <zlib.h>
@@ -218,7 +219,7 @@
ssize_t actual = TEMP_FAILURE_RETRY(read(fd, buf, get_size));
if (actual != get_size) {
- ALOGW("CopyFileToFile: copy read failed (%zd vs %zd)", actual, get_size);
+ ALOGW("CopyFileToFile: copy read failed (" ZD " vs " ZD ")", actual, get_size);
return kIoError;
}
@@ -337,12 +338,12 @@
const off64_t search_start = file_length - read_amount;
if (lseek64(fd, search_start, SEEK_SET) != search_start) {
- ALOGW("Zip: seek %" PRId64 " failed: %s", search_start, strerror(errno));
+ ALOGW("Zip: seek %" PRId64 " failed: %s", (int64_t)search_start, strerror(errno));
return kIoError;
}
ssize_t actual = TEMP_FAILURE_RETRY(read(fd, scan_buffer, read_amount));
if (actual != (ssize_t) read_amount) {
- ALOGW("Zip: read %u failed: %s", read_amount, strerror(errno));
+ ALOGW("Zip: read %" PRIu32 " failed: %s", read_amount, strerror(errno));
return kIoError;
}
@@ -380,7 +381,7 @@
if (dir_offset + dir_size > eocd_offset) {
ALOGW("Zip: bad offsets (dir %" PRId64 ", size %" PRId64 ", eocd %" PRId64 ")",
- dir_offset, dir_size, eocd_offset);
+ (int64_t)dir_offset, (int64_t)dir_size, (int64_t)eocd_offset);
return kInvalidOffset;
}
if (num_entries == 0) {
@@ -389,7 +390,7 @@
}
ALOGV("+++ num_entries=%d dir_size=%" PRId64 " dir_offset=%" PRId64,
- num_entries, dir_size, dir_offset);
+ num_entries, (int64_t)dir_size, (int64_t)dir_offset);
/*
* It all looks good. Create a mapping for the CD, and set the fields
@@ -430,12 +431,12 @@
}
if (file_length > (off64_t) 0xffffffff) {
- ALOGV("Zip: zip file too long %" PRId64, file_length);
+ ALOGV("Zip: zip file too long %" PRId64, (int64_t)file_length);
return kInvalidFile;
}
if (file_length < (int64_t) kEOCDLen) {
- ALOGV("Zip: length %" PRId64 " is too small to be zip", file_length);
+ ALOGV("Zip: length %" PRId64 " is too small to be zip", (int64_t)file_length);
return kInvalidFile;
}
@@ -492,18 +493,18 @@
const uint8_t* ptr = cd_ptr;
for (uint16_t i = 0; i < num_entries; i++) {
if (get4LE(ptr) != kCDESignature) {
- ALOGW("Zip: missed a central dir sig (at %d)", i);
+ ALOGW("Zip: missed a central dir sig (at %" PRIu16 ")", i);
goto bail;
}
if (ptr + kCDELen > cd_ptr + cd_length) {
- ALOGW("Zip: ran off the end (at %d)", i);
+ ALOGW("Zip: ran off the end (at %" PRIu16 ")", i);
goto bail;
}
const off64_t local_header_offset = get4LE(ptr + kCDELocalOffset);
if (local_header_offset >= archive->directory_offset) {
- ALOGW("Zip: bad LFH offset %" PRId64 " at entry %d", local_header_offset, i);
+ ALOGW("Zip: bad LFH offset %" PRId64 " at entry %" PRIu16, (int64_t)local_header_offset, i);
goto bail;
}
@@ -522,12 +523,12 @@
ptr += kCDELen + file_name_length + extra_length + comment_length;
if ((size_t)(ptr - cd_ptr) > cd_length) {
- ALOGW("Zip: bad CD advance (%zu vs %zu) at entry %d",
- (size_t) (ptr - cd_ptr), cd_length, i);
+ ALOGW("Zip: bad CD advance (%tu vs %zu) at entry %" PRIu16,
+ ptr - cd_ptr, cd_length, i);
goto bail;
}
}
- ALOGV("+++ zip good scan %d entries", num_entries);
+ ALOGV("+++ zip good scan %" PRIu16 " entries", num_entries);
result = 0;
@@ -686,13 +687,13 @@
ssize_t actual = ReadAtOffset(archive->fd, lfh_buf, sizeof(lfh_buf),
local_header_offset);
if (actual != sizeof(lfh_buf)) {
- ALOGW("Zip: failed reading lfh name from offset %" PRId64, local_header_offset);
+ ALOGW("Zip: failed reading lfh name from offset %" PRId64, (int64_t)local_header_offset);
return kIoError;
}
if (get4LE(lfh_buf) != kLFHSignature) {
ALOGW("Zip: didn't find signature at start of lfh, offset=%" PRId64,
- local_header_offset);
+ (int64_t)local_header_offset);
return kInvalidOffset;
}
@@ -710,7 +711,8 @@
data->has_data_descriptor = 0;
if (data->compressed_length != lfhCompLen || data->uncompressed_length != lfhUncompLen
|| data->crc32 != lfhCrc) {
- ALOGW("Zip: size/crc32 mismatch. expected {%d, %d, %x}, was {%d, %d, %x}",
+ ALOGW("Zip: size/crc32 mismatch. expected {%" PRIu32 ", %" PRIu32
+ ", %" PRIx32 "}, was {%" PRIu32 ", %" PRIu32 ", %" PRIx32 "}",
data->compressed_length, data->uncompressed_length, data->crc32,
lfhCompLen, lfhUncompLen, lfhCrc);
return kInconsistentInformation;
@@ -733,7 +735,7 @@
name_offset);
if (actual != nameLen) {
- ALOGW("Zip: failed reading lfh name from offset %" PRId64, name_offset);
+ ALOGW("Zip: failed reading lfh name from offset %" PRId64, (int64_t)name_offset);
free(name_buf);
return kIoError;
}
@@ -751,20 +753,20 @@
const off64_t data_offset = local_header_offset + kLFHLen + lfhNameLen + lfhExtraLen;
if (data_offset > cd_offset) {
- ALOGW("Zip: bad data offset %" PRId64 " in zip", data_offset);
+ ALOGW("Zip: bad data offset %" PRId64 " in zip", (int64_t)data_offset);
return kInvalidOffset;
}
if ((off64_t)(data_offset + data->compressed_length) > cd_offset) {
- ALOGW("Zip: bad compressed length in zip (%" PRId64 " + %zd > %" PRId64 ")",
- data_offset, data->compressed_length, cd_offset);
+ ALOGW("Zip: bad compressed length in zip (%" PRId64 " + %" PRIu32 " > %" PRId64 ")",
+ (int64_t)data_offset, data->compressed_length, (int64_t)cd_offset);
return kInvalidOffset;
}
if (data->method == kCompressStored &&
(off64_t)(data_offset + data->uncompressed_length) > cd_offset) {
- ALOGW("Zip: bad uncompressed length in zip (%" PRId64 " + %d > %" PRId64 ")",
- data_offset, data->uncompressed_length, cd_offset);
+ ALOGW("Zip: bad uncompressed length in zip (%" PRId64 " + %" PRIu32 " > %" PRId64 ")",
+ (int64_t)data_offset, data->uncompressed_length, (int64_t)cd_offset);
return kInvalidOffset;
}
@@ -900,10 +902,10 @@
do {
/* read as much as we can */
if (zstream.avail_in == 0) {
- const ssize_t getSize = (compressed_length > kBufSize) ? kBufSize : compressed_length;
- const ssize_t actual = TEMP_FAILURE_RETRY(read(fd, read_buf, getSize));
+ const ZD_TYPE getSize = (compressed_length > kBufSize) ? kBufSize : compressed_length;
+ const ZD_TYPE actual = TEMP_FAILURE_RETRY(read(fd, read_buf, getSize));
if (actual != getSize) {
- ALOGW("Zip: inflate read failed (%zd vs %zd)", actual, getSize);
+ ALOGW("Zip: inflate read failed (" ZD " vs " ZD ")", actual, getSize);
result = kIoError;
goto z_bail;
}
@@ -946,7 +948,7 @@
*crc_out = zstream.adler;
if (zstream.total_out != uncompressed_length || compressed_length != 0) {
- ALOGW("Zip: size mismatch on inflated file (%ld vs %u)",
+ ALOGW("Zip: size mismatch on inflated file (%lu vs %" PRIu32 ")",
zstream.total_out, uncompressed_length);
result = kInconsistentInformation;
goto z_bail;
@@ -967,7 +969,7 @@
off64_t data_offset = entry->offset;
if (lseek64(archive->fd, data_offset, SEEK_SET) != data_offset) {
- ALOGW("Zip: lseek to data at %" PRId64 " failed", data_offset);
+ ALOGW("Zip: lseek to data at %" PRId64 " failed", (int64_t)data_offset);
return kIoError;
}
@@ -990,7 +992,7 @@
// TODO: Fix this check by passing the right flags to inflate2 so that
// it calculates the CRC for us.
if (entry->crc32 != crc && false) {
- ALOGW("Zip: crc mismatch: expected %u, was %" PRIu64, entry->crc32, crc);
+ ALOGW("Zip: crc mismatch: expected %" PRIu32 ", was %" PRIu64, entry->crc32, crc);
return kInconsistentInformation;
}
@@ -1011,7 +1013,7 @@
int result = TEMP_FAILURE_RETRY(ftruncate(fd, declared_length + current_offset));
if (result == -1) {
ALOGW("Zip: unable to truncate file to %" PRId64 ": %s",
- declared_length + current_offset, strerror(errno));
+ (int64_t)(declared_length + current_offset), strerror(errno));
return kIoError;
}
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index ea46345..db4fddd 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -281,6 +281,30 @@
return 0;
}
+static const char multipliers[][2] = {
+ { "" },
+ { "K" },
+ { "M" },
+ { "G" }
+};
+
+static unsigned long value_of_size(unsigned long value)
+{
+ for (unsigned i = 0;
+ (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024);
+ value /= 1024, ++i) ;
+ return value;
+}
+
+static const char *multiplier_of_size(unsigned long value)
+{
+ unsigned i;
+ for (i = 0;
+ (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024);
+ value /= 1024, ++i) ;
+ return multipliers[i];
+}
+
int main(int argc, char **argv)
{
int err;
@@ -715,9 +739,10 @@
exit(EXIT_FAILURE);
}
- printf("%s: ring buffer is %ldKb (%ldKb consumed), "
+ printf("%s: ring buffer is %ld%sb (%ld%sb consumed), "
"max entry is %db, max payload is %db\n", dev->device,
- size / 1024, readable / 1024,
+ value_of_size(size), multiplier_of_size(size),
+ value_of_size(readable), multiplier_of_size(readable),
(int) LOGGER_ENTRY_MAX_LEN, (int) LOGGER_ENTRY_MAX_PAYLOAD);
}
diff --git a/logcat/tests/Android.mk b/logcat/tests/Android.mk
index d42b3d0..5d4d29e 100644
--- a/logcat/tests/Android.mk
+++ b/logcat/tests/Android.mk
@@ -40,7 +40,6 @@
LOCAL_MODULE_TAGS := $(test_tags)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += $(test_c_flags)
-LOCAL_LDLIBS := -lpthread
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_SRC_FILES := $(test_src_files)
include $(BUILD_NATIVE_TEST)
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 38a237c..dc9d47e 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -14,29 +14,68 @@
* limitations under the License.
*/
+#include <ctype.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <cutils/properties.h>
#include <log/logger.h>
#include "LogBuffer.h"
+#include "LogReader.h"
#include "LogStatistics.h"
#include "LogWhiteBlackList.h"
-#include "LogReader.h"
// Default
#define LOG_BUFFER_SIZE (256 * 1024) // Tuned on a per-platform basis here?
#define log_buffer_size(id) mMaxSize[id]
+static unsigned long property_get_size(const char *key) {
+ char property[PROPERTY_VALUE_MAX];
+ property_get(key, property, "");
+
+ char *cp;
+ unsigned long value = strtoul(property, &cp, 10);
+
+ switch(*cp) {
+ case 'm':
+ case 'M':
+ value *= 1024;
+ /* FALLTHRU */
+ case 'k':
+ case 'K':
+ value *= 1024;
+ /* FALLTHRU */
+ case '\0':
+ break;
+
+ default:
+ value = 0;
+ }
+
+ return value;
+}
+
LogBuffer::LogBuffer(LastLogTimes *times)
: mTimes(*times) {
pthread_mutex_init(&mLogElementsLock, NULL);
dgram_qlen_statistics = false;
+ static const char global_default[] = "persist.logd.size";
+ unsigned long default_size = property_get_size(global_default);
+
log_id_for_each(i) {
- mMaxSize[i] = LOG_BUFFER_SIZE;
+ setSize(i, LOG_BUFFER_SIZE);
+ setSize(i, default_size);
+
+ char key[PROP_NAME_MAX];
+ snprintf(key, sizeof(key), "%s.%s",
+ global_default, android_log_id_to_name(i));
+
+ setSize(i, property_get_size(key));
}
}
diff --git a/logd/LogWhiteBlackList.cpp b/logd/LogWhiteBlackList.cpp
index c6c7b23..e87b604 100644
--- a/logd/LogWhiteBlackList.cpp
+++ b/logd/LogWhiteBlackList.cpp
@@ -47,7 +47,7 @@
}
PruneList::PruneList()
- : mWorstUidEnabled(true) {
+ : mWorstUidEnabled(false) {
mNaughty.clear();
mNice.clear();
}
@@ -65,7 +65,7 @@
}
int PruneList::init(char *str) {
- mWorstUidEnabled = true;
+ mWorstUidEnabled = false;
PruneCollection::iterator it;
for (it = mNice.begin(); it != mNice.end();) {
delete (*it);
diff --git a/logd/README.property b/logd/README.property
index 5d92d09..f4b3c3c 100644
--- a/logd/README.property
+++ b/logd/README.property
@@ -10,3 +10,16 @@
minimum domain socket network FIFO
size (see source for details) based
on typical load (logcat -S to view)
+persist.logd.size number 256K default size of the buffer for all
+ log ids at initial startup, at runtime
+ use: logcat -b all -G <value>
+persist.logd.size.main number 256K Size of the buffer for the main log
+persist.logd.size.system number 256K Size of the buffer for the system log
+persist.logd.size.radio number 256K Size of the buffer for the radio log
+persist.logd.size.event number 256K Size of the buffer for the event log
+persist.logd.size.crash number 256K Size of the buffer for the crash log
+
+NB:
+- number support multipliers (K or M) for convenience. Range is limited
+ to between 64K and 256M for log buffer sizes. Individual logs override the
+ global default.
diff --git a/mkbootimg/Android.mk b/mkbootimg/Android.mk
index 2a97c26..0c9b0c6 100644
--- a/mkbootimg/Android.mk
+++ b/mkbootimg/Android.mk
@@ -4,6 +4,7 @@
LOCAL_SRC_FILES := mkbootimg.c
LOCAL_STATIC_LIBRARIES := libmincrypt
+LOCAL_CFLAGS := -Werror
LOCAL_MODULE := mkbootimg
diff --git a/mkbootimg/mkbootimg.c b/mkbootimg/mkbootimg.c
index a7daccc..fc92b4d 100644
--- a/mkbootimg/mkbootimg.c
+++ b/mkbootimg/mkbootimg.c
@@ -77,7 +77,7 @@
int write_padding(int fd, unsigned pagesize, unsigned itemsize)
{
unsigned pagemask = pagesize - 1;
- unsigned count;
+ ssize_t count;
if((itemsize & pagemask) == 0) {
return 0;
@@ -108,7 +108,7 @@
unsigned pagesize = 2048;
int fd;
SHA_CTX ctx;
- uint8_t* sha;
+ const uint8_t* sha;
unsigned base = 0x10000000;
unsigned kernel_offset = 0x00008000;
unsigned ramdisk_offset = 0x01000000;
@@ -189,7 +189,7 @@
return usage();
}
- strcpy(hdr.name, board);
+ strcpy((char *) hdr.name, board);
memcpy(hdr.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE);
@@ -255,14 +255,14 @@
if(write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) goto fail;
if(write_padding(fd, pagesize, sizeof(hdr))) goto fail;
- if(write(fd, kernel_data, hdr.kernel_size) != hdr.kernel_size) goto fail;
+ if(write(fd, kernel_data, hdr.kernel_size) != (ssize_t) hdr.kernel_size) goto fail;
if(write_padding(fd, pagesize, hdr.kernel_size)) goto fail;
- if(write(fd, ramdisk_data, hdr.ramdisk_size) != hdr.ramdisk_size) goto fail;
+ if(write(fd, ramdisk_data, hdr.ramdisk_size) != (ssize_t) hdr.ramdisk_size) goto fail;
if(write_padding(fd, pagesize, hdr.ramdisk_size)) goto fail;
if(second_data) {
- if(write(fd, second_data, hdr.second_size) != hdr.second_size) goto fail;
+ if(write(fd, second_data, hdr.second_size) != (ssize_t) hdr.second_size) goto fail;
if(write_padding(fd, pagesize, hdr.second_size)) goto fail;
}
diff --git a/netcfg/Android.mk b/netcfg/Android.mk
index 949f417..fc01a54 100644
--- a/netcfg/Android.mk
+++ b/netcfg/Android.mk
@@ -11,6 +11,7 @@
#LOCAL_STATIC_LIBRARIES := libcutils libc
LOCAL_SHARED_LIBRARIES := libc libnetutils
+LOCAL_CFLAGS := -Werror
include $(BUILD_EXECUTABLE)
endif
diff --git a/netcfg/netcfg.c b/netcfg/netcfg.c
index 3738f24..2308f37 100644
--- a/netcfg/netcfg.c
+++ b/netcfg/netcfg.c
@@ -1,5 +1,4 @@
-/* system/bin/netcfg/netcfg.c
-**
+/*
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,18 +14,14 @@
** limitations under the License.
*/
-#include <stdio.h>
-#include <stdlib.h>
#include <errno.h>
#include <dirent.h>
#include <netinet/ether.h>
#include <netinet/if_ether.h>
-
-#include <netutils/ifc.h>
#include <netutils/dhcp.h>
-
-static int verbose = 0;
-
+#include <netutils/ifc.h>
+#include <stdio.h>
+#include <stdlib.h>
void die(const char *reason)
{
diff --git a/run-as/Android.mk b/run-as/Android.mk
index a8f2885..3774acc 100644
--- a/run-as/Android.mk
+++ b/run-as/Android.mk
@@ -1,10 +1,12 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES:= run-as.c package.c
+LOCAL_SRC_FILES := run-as.c package.c
LOCAL_SHARED_LIBRARIES := libselinux
-LOCAL_MODULE:= run-as
+LOCAL_MODULE := run-as
+
+LOCAL_CFLAGS := -Werror
include $(BUILD_EXECUTABLE)
diff --git a/run-as/package.c b/run-as/package.c
index 901e9e3..4f8f3a7 100644
--- a/run-as/package.c
+++ b/run-as/package.c
@@ -128,7 +128,9 @@
}
/* Memory-map the file now */
- address = TEMP_FAILURE_RETRY(mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, 0));
+ do {
+ address = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, 0);
+ } while (address == MAP_FAILED && errno == EINTR);
if (address == MAP_FAILED) {
address = NULL;
goto EXIT;
@@ -408,10 +410,6 @@
value = -1;
}
return value;
-
-BAD:
- *pp = p;
- return -1;
}
/* Read the system's package database and extract information about
diff --git a/sdcard/fuse.h b/sdcard/fuse.h
deleted file mode 100644
index 3138da9..0000000
--- a/sdcard/fuse.h
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- FUSE: Filesystem in Userspace
- Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
-
- This program can be distributed under the terms of the GNU GPL.
- See the file COPYING.
-*/
-
-/*
- * from the libfuse FAQ (and consistent with the Linux Kernel license):
- *
- * Under what conditions may I distribute a filesystem that uses the
- * raw kernel interface of FUSE?
- *
- * There are no restrictions whatsoever for using the raw kernel interface.
- *
- */
-
-/*
- * This file defines the kernel interface of FUSE
- *
- * Protocol changelog:
- *
- * 7.9:
- * - new fuse_getattr_in input argument of GETATTR
- * - add lk_flags in fuse_lk_in
- * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
- * - add blksize field to fuse_attr
- * - add file flags field to fuse_read_in and fuse_write_in
- *
- * 7.10
- * - add nonseekable open flag
- *
- * 7.11
- * - add IOCTL message
- * - add unsolicited notification support
- * - add POLL message and NOTIFY_POLL notification
- *
- * 7.12
- * - add umask flag to input argument of open, mknod and mkdir
- * - add notification messages for invalidation of inodes and
- * directory entries
- *
- * 7.13
- * - make max number of background requests and congestion threshold
- * tunables
- */
-
-#ifndef _LINUX_FUSE_H
-#define _LINUX_FUSE_H
-
-#include <linux/types.h>
-
-/*
- * Version negotiation:
- *
- * Both the kernel and userspace send the version they support in the
- * INIT request and reply respectively.
- *
- * If the major versions match then both shall use the smallest
- * of the two minor versions for communication.
- *
- * If the kernel supports a larger major version, then userspace shall
- * reply with the major version it supports, ignore the rest of the
- * INIT message and expect a new INIT message from the kernel with a
- * matching major version.
- *
- * If the library supports a larger major version, then it shall fall
- * back to the major protocol version sent by the kernel for
- * communication and reply with that major version (and an arbitrary
- * supported minor version).
- */
-
-/** Version number of this interface */
-#define FUSE_KERNEL_VERSION 7
-
-/** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 13
-
-/** The node ID of the root inode */
-#define FUSE_ROOT_ID 1
-
-/* Make sure all structures are padded to 64bit boundary, so 32bit
- userspace works under 64bit kernels */
-
-struct fuse_attr {
- __u64 ino;
- __u64 size;
- __u64 blocks;
- __u64 atime;
- __u64 mtime;
- __u64 ctime;
- __u32 atimensec;
- __u32 mtimensec;
- __u32 ctimensec;
- __u32 mode;
- __u32 nlink;
- __u32 uid;
- __u32 gid;
- __u32 rdev;
- __u32 blksize;
- __u32 padding;
-};
-
-struct fuse_kstatfs {
- __u64 blocks;
- __u64 bfree;
- __u64 bavail;
- __u64 files;
- __u64 ffree;
- __u32 bsize;
- __u32 namelen;
- __u32 frsize;
- __u32 padding;
- __u32 spare[6];
-};
-
-struct fuse_file_lock {
- __u64 start;
- __u64 end;
- __u32 type;
- __u32 pid; /* tgid */
-};
-
-/**
- * Bitmasks for fuse_setattr_in.valid
- */
-#define FATTR_MODE (1 << 0)
-#define FATTR_UID (1 << 1)
-#define FATTR_GID (1 << 2)
-#define FATTR_SIZE (1 << 3)
-#define FATTR_ATIME (1 << 4)
-#define FATTR_MTIME (1 << 5)
-#define FATTR_FH (1 << 6)
-#define FATTR_ATIME_NOW (1 << 7)
-#define FATTR_MTIME_NOW (1 << 8)
-#define FATTR_LOCKOWNER (1 << 9)
-
-/**
- * Flags returned by the OPEN request
- *
- * FOPEN_DIRECT_IO: bypass page cache for this open file
- * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
- * FOPEN_NONSEEKABLE: the file is not seekable
- */
-#define FOPEN_DIRECT_IO (1 << 0)
-#define FOPEN_KEEP_CACHE (1 << 1)
-#define FOPEN_NONSEEKABLE (1 << 2)
-
-/**
- * INIT request/reply flags
- *
- * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
- * FUSE_DONT_MASK: don't apply umask to file mode on create operations
- */
-#define FUSE_ASYNC_READ (1 << 0)
-#define FUSE_POSIX_LOCKS (1 << 1)
-#define FUSE_FILE_OPS (1 << 2)
-#define FUSE_ATOMIC_O_TRUNC (1 << 3)
-#define FUSE_EXPORT_SUPPORT (1 << 4)
-#define FUSE_BIG_WRITES (1 << 5)
-#define FUSE_DONT_MASK (1 << 6)
-
-/**
- * CUSE INIT request/reply flags
- *
- * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl
- */
-#define CUSE_UNRESTRICTED_IOCTL (1 << 0)
-
-/**
- * Release flags
- */
-#define FUSE_RELEASE_FLUSH (1 << 0)
-
-/**
- * Getattr flags
- */
-#define FUSE_GETATTR_FH (1 << 0)
-
-/**
- * Lock flags
- */
-#define FUSE_LK_FLOCK (1 << 0)
-
-/**
- * WRITE flags
- *
- * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
- * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
- */
-#define FUSE_WRITE_CACHE (1 << 0)
-#define FUSE_WRITE_LOCKOWNER (1 << 1)
-
-/**
- * Read flags
- */
-#define FUSE_READ_LOCKOWNER (1 << 1)
-
-/**
- * Ioctl flags
- *
- * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
- * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
- * FUSE_IOCTL_RETRY: retry with new iovecs
- *
- * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
- */
-#define FUSE_IOCTL_COMPAT (1 << 0)
-#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
-#define FUSE_IOCTL_RETRY (1 << 2)
-
-#define FUSE_IOCTL_MAX_IOV 256
-
-/**
- * Poll flags
- *
- * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
- */
-#define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
-
-enum fuse_opcode {
- FUSE_LOOKUP = 1,
- FUSE_FORGET = 2, /* no reply */
- FUSE_GETATTR = 3,
- FUSE_SETATTR = 4,
- FUSE_READLINK = 5,
- FUSE_SYMLINK = 6,
- FUSE_MKNOD = 8,
- FUSE_MKDIR = 9,
- FUSE_UNLINK = 10,
- FUSE_RMDIR = 11,
- FUSE_RENAME = 12,
- FUSE_LINK = 13,
- FUSE_OPEN = 14,
- FUSE_READ = 15,
- FUSE_WRITE = 16,
- FUSE_STATFS = 17,
- FUSE_RELEASE = 18,
- FUSE_FSYNC = 20,
- FUSE_SETXATTR = 21,
- FUSE_GETXATTR = 22,
- FUSE_LISTXATTR = 23,
- FUSE_REMOVEXATTR = 24,
- FUSE_FLUSH = 25,
- FUSE_INIT = 26,
- FUSE_OPENDIR = 27,
- FUSE_READDIR = 28,
- FUSE_RELEASEDIR = 29,
- FUSE_FSYNCDIR = 30,
- FUSE_GETLK = 31,
- FUSE_SETLK = 32,
- FUSE_SETLKW = 33,
- FUSE_ACCESS = 34,
- FUSE_CREATE = 35,
- FUSE_INTERRUPT = 36,
- FUSE_BMAP = 37,
- FUSE_DESTROY = 38,
- FUSE_IOCTL = 39,
- FUSE_POLL = 40,
-
- /* CUSE specific operations */
- CUSE_INIT = 4096,
-};
-
-enum fuse_notify_code {
- FUSE_NOTIFY_POLL = 1,
- FUSE_NOTIFY_INVAL_INODE = 2,
- FUSE_NOTIFY_INVAL_ENTRY = 3,
- FUSE_NOTIFY_CODE_MAX,
-};
-
-/* The read buffer is required to be at least 8k, but may be much larger */
-#define FUSE_MIN_READ_BUFFER 8192
-
-#define FUSE_COMPAT_ENTRY_OUT_SIZE 120
-
-struct fuse_entry_out {
- __u64 nodeid; /* Inode ID */
- __u64 generation; /* Inode generation: nodeid:gen must
- be unique for the fs's lifetime */
- __u64 entry_valid; /* Cache timeout for the name */
- __u64 attr_valid; /* Cache timeout for the attributes */
- __u32 entry_valid_nsec;
- __u32 attr_valid_nsec;
- struct fuse_attr attr;
-};
-
-struct fuse_forget_in {
- __u64 nlookup;
-};
-
-struct fuse_getattr_in {
- __u32 getattr_flags;
- __u32 dummy;
- __u64 fh;
-};
-
-#define FUSE_COMPAT_ATTR_OUT_SIZE 96
-
-struct fuse_attr_out {
- __u64 attr_valid; /* Cache timeout for the attributes */
- __u32 attr_valid_nsec;
- __u32 dummy;
- struct fuse_attr attr;
-};
-
-#define FUSE_COMPAT_MKNOD_IN_SIZE 8
-
-struct fuse_mknod_in {
- __u32 mode;
- __u32 rdev;
- __u32 umask;
- __u32 padding;
-};
-
-struct fuse_mkdir_in {
- __u32 mode;
- __u32 umask;
-};
-
-struct fuse_rename_in {
- __u64 newdir;
-};
-
-struct fuse_link_in {
- __u64 oldnodeid;
-};
-
-struct fuse_setattr_in {
- __u32 valid;
- __u32 padding;
- __u64 fh;
- __u64 size;
- __u64 lock_owner;
- __u64 atime;
- __u64 mtime;
- __u64 unused2;
- __u32 atimensec;
- __u32 mtimensec;
- __u32 unused3;
- __u32 mode;
- __u32 unused4;
- __u32 uid;
- __u32 gid;
- __u32 unused5;
-};
-
-struct fuse_open_in {
- __u32 flags;
- __u32 unused;
-};
-
-struct fuse_create_in {
- __u32 flags;
- __u32 mode;
- __u32 umask;
- __u32 padding;
-};
-
-struct fuse_open_out {
- __u64 fh;
- __u32 open_flags;
- __u32 padding;
-};
-
-struct fuse_release_in {
- __u64 fh;
- __u32 flags;
- __u32 release_flags;
- __u64 lock_owner;
-};
-
-struct fuse_flush_in {
- __u64 fh;
- __u32 unused;
- __u32 padding;
- __u64 lock_owner;
-};
-
-struct fuse_read_in {
- __u64 fh;
- __u64 offset;
- __u32 size;
- __u32 read_flags;
- __u64 lock_owner;
- __u32 flags;
- __u32 padding;
-};
-
-#define FUSE_COMPAT_WRITE_IN_SIZE 24
-
-struct fuse_write_in {
- __u64 fh;
- __u64 offset;
- __u32 size;
- __u32 write_flags;
- __u64 lock_owner;
- __u32 flags;
- __u32 padding;
-};
-
-struct fuse_write_out {
- __u32 size;
- __u32 padding;
-};
-
-#define FUSE_COMPAT_STATFS_SIZE 48
-
-struct fuse_statfs_out {
- struct fuse_kstatfs st;
-};
-
-struct fuse_fsync_in {
- __u64 fh;
- __u32 fsync_flags;
- __u32 padding;
-};
-
-struct fuse_setxattr_in {
- __u32 size;
- __u32 flags;
-};
-
-struct fuse_getxattr_in {
- __u32 size;
- __u32 padding;
-};
-
-struct fuse_getxattr_out {
- __u32 size;
- __u32 padding;
-};
-
-struct fuse_lk_in {
- __u64 fh;
- __u64 owner;
- struct fuse_file_lock lk;
- __u32 lk_flags;
- __u32 padding;
-};
-
-struct fuse_lk_out {
- struct fuse_file_lock lk;
-};
-
-struct fuse_access_in {
- __u32 mask;
- __u32 padding;
-};
-
-struct fuse_init_in {
- __u32 major;
- __u32 minor;
- __u32 max_readahead;
- __u32 flags;
-};
-
-struct fuse_init_out {
- __u32 major;
- __u32 minor;
- __u32 max_readahead;
- __u32 flags;
- __u16 max_background;
- __u16 congestion_threshold;
- __u32 max_write;
-};
-
-#define CUSE_INIT_INFO_MAX 4096
-
-struct cuse_init_in {
- __u32 major;
- __u32 minor;
- __u32 unused;
- __u32 flags;
-};
-
-struct cuse_init_out {
- __u32 major;
- __u32 minor;
- __u32 unused;
- __u32 flags;
- __u32 max_read;
- __u32 max_write;
- __u32 dev_major; /* chardev major */
- __u32 dev_minor; /* chardev minor */
- __u32 spare[10];
-};
-
-struct fuse_interrupt_in {
- __u64 unique;
-};
-
-struct fuse_bmap_in {
- __u64 block;
- __u32 blocksize;
- __u32 padding;
-};
-
-struct fuse_bmap_out {
- __u64 block;
-};
-
-struct fuse_ioctl_in {
- __u64 fh;
- __u32 flags;
- __u32 cmd;
- __u64 arg;
- __u32 in_size;
- __u32 out_size;
-};
-
-struct fuse_ioctl_out {
- __s32 result;
- __u32 flags;
- __u32 in_iovs;
- __u32 out_iovs;
-};
-
-struct fuse_poll_in {
- __u64 fh;
- __u64 kh;
- __u32 flags;
- __u32 padding;
-};
-
-struct fuse_poll_out {
- __u32 revents;
- __u32 padding;
-};
-
-struct fuse_notify_poll_wakeup_out {
- __u64 kh;
-};
-
-struct fuse_in_header {
- __u32 len;
- __u32 opcode;
- __u64 unique;
- __u64 nodeid;
- __u32 uid;
- __u32 gid;
- __u32 pid;
- __u32 padding;
-};
-
-struct fuse_out_header {
- __u32 len;
- __s32 error;
- __u64 unique;
-};
-
-struct fuse_dirent {
- __u64 ino;
- __u64 off;
- __u32 namelen;
- __u32 type;
- char name[0];
-};
-
-#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
-#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
-#define FUSE_DIRENT_SIZE(d) \
- FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
-
-struct fuse_notify_inval_inode_out {
- __u64 ino;
- __s64 off;
- __s64 len;
-};
-
-struct fuse_notify_inval_entry_out {
- __u64 parent;
- __u32 namelen;
- __u32 padding;
-};
-
-#endif /* _LINUX_FUSE_H */
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 6a9c2eb..7baad63 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -14,23 +14,24 @@
* limitations under the License.
*/
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <linux/fuse.h>
+#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
+#include <sys/inotify.h>
#include <sys/mount.h>
+#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/statfs.h>
-#include <sys/uio.h>
-#include <dirent.h>
-#include <limits.h>
-#include <ctype.h>
-#include <pthread.h>
#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/inotify.h>
+#include <sys/uio.h>
+#include <unistd.h>
#include <cutils/fs.h>
#include <cutils/hashmap.h>
@@ -38,15 +39,13 @@
#include <private/android_filesystem_config.h>
-#include "fuse.h"
-
/* README
*
* What is this?
- *
+ *
* sdcard is a program that uses FUSE to emulate FAT-on-sdcard style
- * directory permissions (all files are given fixed owner, group, and
- * permissions at creation, owner, group, and permissions are not
+ * directory permissions (all files are given fixed owner, group, and
+ * permissions at creation, owner, group, and permissions are not
* changeable, symlinks and hardlinks are not createable, etc.
*
* See usage() for command line options.
@@ -1245,7 +1244,7 @@
struct handle *h = id_to_ptr(req->fh);
int res;
__u8 aligned_buffer[req->size] __attribute__((__aligned__(PAGESIZE)));
-
+
if (req->flags & O_DIRECT) {
memcpy(aligned_buffer, buffer, req->size);
buffer = (const __u8*) aligned_buffer;