diff options
Diffstat (limited to 'libcutils')
-rw-r--r-- | libcutils/Android.mk | 25 | ||||
-rw-r--r-- | libcutils/ashmem-host.c | 26 | ||||
-rw-r--r-- | libcutils/cpu_info.c | 9 | ||||
-rw-r--r-- | libcutils/debugger.c | 5 | ||||
-rw-r--r-- | libcutils/dlmalloc_stubs.c | 10 | ||||
-rw-r--r-- | libcutils/iosched_policy.c | 14 | ||||
-rw-r--r-- | libcutils/partition_utils.c | 9 | ||||
-rw-r--r-- | libcutils/process_name.c | 18 | ||||
-rw-r--r-- | libcutils/qtaguid.c | 7 | ||||
-rw-r--r-- | libcutils/sched_policy.c | 19 | ||||
-rw-r--r-- | libcutils/socket_inaddr_any_server.c | 14 | ||||
-rw-r--r-- | libcutils/socket_local_client.c | 9 | ||||
-rw-r--r-- | libcutils/socket_loopback_client.c | 12 | ||||
-rw-r--r-- | libcutils/socket_loopback_server.c | 14 | ||||
-rw-r--r-- | libcutils/socket_network_client.c | 11 | ||||
-rw-r--r-- | libcutils/sockets.c | 7 | ||||
-rw-r--r-- | libcutils/str_parms.c | 62 | ||||
-rw-r--r-- | libcutils/threads.c | 6 | ||||
-rw-r--r-- | libcutils/trace.c | 3 |
19 files changed, 163 insertions, 117 deletions
diff --git a/libcutils/Android.mk b/libcutils/Android.mk index 93bccb0..2dcc965 100644 --- a/libcutils/Android.mk +++ b/libcutils/Android.mk @@ -78,6 +78,9 @@ LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c LOCAL_LDLIBS := -lpthread LOCAL_STATIC_LIBRARIES := liblog LOCAL_CFLAGS += $(hostSmpFlag) +ifneq ($(HOST_OS),windows) +LOCAL_CFLAGS += -Werror +endif include $(BUILD_HOST_STATIC_LIBRARY) @@ -89,8 +92,24 @@ LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c LOCAL_LDLIBS := -lpthread LOCAL_STATIC_LIBRARIES := lib64log LOCAL_CFLAGS += $(hostSmpFlag) -m64 +ifneq ($(HOST_OS),windows) +LOCAL_CFLAGS += -Werror +endif include $(BUILD_HOST_STATIC_LIBRARY) +# Tests for host +# ======================================================== +include $(CLEAR_VARS) +LOCAL_MODULE := tst_str_parms +LOCAL_CFLAGS += -DTEST_STR_PARMS +ifneq ($(HOST_OS),windows) +LOCAL_CFLAGS += -Werror +endif +LOCAL_SRC_FILES := str_parms.c hashmap.c memory.c +LOCAL_STATIC_LIBRARIES := liblog +LOCAL_MODULE_TAGS := optional +include $(BUILD_HOST_EXECUTABLE) + # Shared and static library for target # ======================================================== @@ -125,7 +144,7 @@ endif # !arm LOCAL_C_INCLUDES := $(libcutils_c_includes) LOCAL_STATIC_LIBRARIES := liblog -LOCAL_CFLAGS += $(targetSmpFlag) +LOCAL_CFLAGS += $(targetSmpFlag) -Werror include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) @@ -134,13 +153,13 @@ LOCAL_MODULE := libcutils # liblog symbols present in libcutils. LOCAL_WHOLE_STATIC_LIBRARIES := libcutils liblog LOCAL_SHARED_LIBRARIES := liblog -LOCAL_CFLAGS += $(targetSmpFlag) +LOCAL_CFLAGS += $(targetSmpFlag) -Werror LOCAL_C_INCLUDES := $(libcutils_c_includes) include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := tst_str_parms -LOCAL_CFLAGS += -DTEST_STR_PARMS +LOCAL_CFLAGS += -DTEST_STR_PARMS -Werror LOCAL_SRC_FILES := str_parms.c hashmap.c memory.c LOCAL_SHARED_LIBRARIES := liblog LOCAL_MODULE_TAGS := optional diff --git a/libcutils/ashmem-host.c b/libcutils/ashmem-host.c index f03e130..7873964 100644 --- a/libcutils/ashmem-host.c +++ b/libcutils/ashmem-host.c @@ -19,20 +19,24 @@ * an ashmem-enabled kernel. See ashmem-dev.c for the real ashmem-based version. */ -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> +#include <errno.h> #include <fcntl.h> +#include <limits.h> #include <stdio.h> -#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> #include <time.h> -#include <limits.h> +#include <unistd.h> #include <cutils/ashmem.h> -int ashmem_create_region(const char *ignored, size_t size) +#ifndef __unused +#define __unused __attribute__((__unused__)) +#endif + +int ashmem_create_region(const char *ignored __unused, size_t size) { static const char txt[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -78,17 +82,17 @@ error: return -1; } -int ashmem_set_prot_region(int fd, int prot) +int ashmem_set_prot_region(int fd __unused, int prot __unused) { return 0; } -int ashmem_pin_region(int fd, size_t offset, size_t len) +int ashmem_pin_region(int fd __unused, size_t offset __unused, size_t len __unused) { return ASHMEM_NOT_PURGED; } -int ashmem_unpin_region(int fd, size_t offset, size_t len) +int ashmem_unpin_region(int fd __unused, size_t offset __unused, size_t len __unused) { return ASHMEM_IS_UNPINNED; } diff --git a/libcutils/cpu_info.c b/libcutils/cpu_info.c index 23dda8a..21fa1dc 100644 --- a/libcutils/cpu_info.c +++ b/libcutils/cpu_info.c @@ -1,5 +1,4 @@ -/* libs/cutils/cpu_info.c -** +/* ** Copyright 2007, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,11 +14,12 @@ ** limitations under the License. */ -#include <cutils/cpu_info.h> -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> +#include <cutils/cpu_info.h> + // we cache the serial number here. // this is also used as a fgets() line buffer when we are reading /proc/cpuinfo static char serial_number[100] = { 0 }; @@ -31,7 +31,6 @@ extern const char* get_cpu_serial_number(void) FILE* file; char* chp, *end; char* whitespace; - int length; // read serial number from /proc/cpuinfo file = fopen("proc/cpuinfo", "r"); diff --git a/libcutils/debugger.c b/libcutils/debugger.c index 7d907fc..056de5d 100644 --- a/libcutils/debugger.c +++ b/libcutils/debugger.c @@ -15,6 +15,7 @@ */ #include <stdlib.h> +#include <string.h> #include <unistd.h> #include <cutils/debugger.h> @@ -28,9 +29,9 @@ int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen) { } debugger_msg_t msg; + memset(&msg, 0, sizeof(msg)); msg.tid = tid; msg.action = DEBUGGER_ACTION_DUMP_TOMBSTONE; - msg.abort_msg_address = 0; int result = 0; if (TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg))) != sizeof(msg)) { @@ -62,9 +63,9 @@ int dump_backtrace_to_file(pid_t tid, int fd) { } debugger_msg_t msg; + memset(&msg, 0, sizeof(msg)); msg.tid = tid; msg.action = DEBUGGER_ACTION_DUMP_BACKTRACE; - msg.abort_msg_address = 0; int result = 0; if (TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg))) != sizeof(msg)) { diff --git a/libcutils/dlmalloc_stubs.c b/libcutils/dlmalloc_stubs.c index c327a55..6dca911 100644 --- a/libcutils/dlmalloc_stubs.c +++ b/libcutils/dlmalloc_stubs.c @@ -15,20 +15,22 @@ */ #include "../../../bionic/libc/bionic/dlmalloc.h" -#include "cutils/log.h" +#include "log/log.h" + +#define UNUSED __attribute__((__unused__)) /* * Stubs for functions defined in bionic/libc/bionic/dlmalloc.c. These * are used in host builds, as the host libc will not contain these * functions. */ -void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), - void* arg) +void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*) UNUSED, + void* arg UNUSED) { ALOGW("Called host unimplemented stub: dlmalloc_inspect_all"); } -int dlmalloc_trim(size_t unused) +int dlmalloc_trim(size_t unused UNUSED) { ALOGW("Called host unimplemented stub: dlmalloc_trim"); return 0; diff --git a/libcutils/iosched_policy.c b/libcutils/iosched_policy.c index 5d90a01..67e101d 100644 --- a/libcutils/iosched_policy.c +++ b/libcutils/iosched_policy.c @@ -1,5 +1,4 @@ /* -** ** Copyright 2007-2014, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,12 +14,12 @@ ** limitations under the License. */ +#include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> -#include <errno.h> -#include <fcntl.h> +#include <unistd.h> #ifdef HAVE_SCHED_H @@ -30,6 +29,9 @@ /* #include <linux/ioprio.h> */ extern int ioprio_set(int which, int who, int ioprio); extern int ioprio_get(int which, int who); +#define __android_unused +#else +#define __android_unused __attribute__((__unused__)) #endif enum { @@ -41,7 +43,7 @@ enum { #define CLASS_SHIFT 13 #define IOPRIO_NORM 4 -int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio) { +int android_set_ioprio(int pid __android_unused, IoSchedClass clazz __android_unused, int ioprio __android_unused) { #ifdef HAVE_ANDROID_OS if (ioprio_set(WHO_PROCESS, pid, ioprio | (clazz << CLASS_SHIFT))) { return -1; @@ -50,7 +52,7 @@ int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio) { return 0; } -int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio) { +int android_get_ioprio(int pid __android_unused, IoSchedClass *clazz, int *ioprio) { #ifdef HAVE_ANDROID_OS int rc; diff --git a/libcutils/partition_utils.c b/libcutils/partition_utils.c index 10539fa..823b162 100644 --- a/libcutils/partition_utils.c +++ b/libcutils/partition_utils.c @@ -14,12 +14,13 @@ * limitations under the License. */ -#include <sys/types.h> -#include <unistd.h> #include <fcntl.h> -#include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mount.h> /* for BLKGETSIZE */ +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> + #include <cutils/properties.h> static int only_one_char(char *buf, int len, char c) @@ -39,7 +40,7 @@ static int only_one_char(char *buf, int len, char c) int partition_wiped(char *source) { char buf[4096]; - int fd, ret, wiped; + int fd, ret; if ((fd = open(source, O_RDONLY)) < 0) { return 0; diff --git a/libcutils/process_name.c b/libcutils/process_name.c index a6ab951..9c3dfb8 100644 --- a/libcutils/process_name.c +++ b/libcutils/process_name.c @@ -14,25 +14,27 @@ * limitations under the License. */ +#include <fcntl.h> #include <stdlib.h> #include <string.h> -#include <cutils/process_name.h> -#ifdef HAVE_ANDROID_OS -#include <cutils/properties.h> +#if defined(HAVE_PRCTL) +#include <sys/prctl.h> #endif -#include <unistd.h> -#include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> +#include <sys/types.h> +#include <unistd.h> -#if defined(HAVE_PRCTL) -#include <sys/prctl.h> +#include <cutils/process_name.h> +#ifdef HAVE_ANDROID_OS +#include <cutils/properties.h> #endif #define PROCESS_NAME_DEVICE "/sys/qemu_trace/process_name" static const char* process_name = "unknown"; +#ifdef HAVE_ANDROID_OS static int running_in_emulator = -1; +#endif void set_process_name(const char* new_name) { #ifdef HAVE_ANDROID_OS diff --git a/libcutils/qtaguid.c b/libcutils/qtaguid.c index 899a7b4..00e211c 100644 --- a/libcutils/qtaguid.c +++ b/libcutils/qtaguid.c @@ -1,5 +1,4 @@ -/* libcutils/qtaguid.c -** +/* ** Copyright 2011, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -146,7 +145,7 @@ int qtaguid_setCounterSet(int counterSetNum, uid_t uid) { int qtaguid_deleteTagData(int tag, uid_t uid) { char lineBuf[CTRL_MAX_INPUT_LEN]; - int fd, cnt = 0, res = 0; + int cnt = 0, res = 0; uint64_t kTag = (uint64_t)tag << 32; ALOGV("Deleting tag data with tag %" PRIx64 "{%d,0} for uid %d", kTag, tag, uid); @@ -164,8 +163,6 @@ int qtaguid_deleteTagData(int tag, uid_t uid) { } int qtaguid_setPacifier(int on) { - int param_fd; - int res; const char *value; value = on ? "Y" : "N"; diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c index d20d217..9f092d6 100644 --- a/libcutils/sched_policy.c +++ b/libcutils/sched_policy.c @@ -1,6 +1,4 @@ - -/* libs/cutils/sched_policy.c -** +/* ** Copyright 2007, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,14 +16,17 @@ #define LOG_TAG "SchedPolicy" +#include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> -#include <errno.h> -#include <fcntl.h> +#include <unistd.h> + #include <cutils/sched_policy.h> -#include <cutils/log.h> +#include <log/log.h> + +#define UNUSED __attribute__((__unused__)) /* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged. * Call this any place a SchedPolicy is used as an input parameter. @@ -331,12 +332,12 @@ int set_sched_policy(int tid, SchedPolicy policy) /* Stubs for non-Android targets. */ -int set_sched_policy(int tid, SchedPolicy policy) +int set_sched_policy(int tid UNUSED, SchedPolicy policy UNUSED) { return 0; } -int get_sched_policy(int tid, SchedPolicy *policy) +int get_sched_policy(int tid UNUSED, SchedPolicy *policy) { *policy = SP_SYSTEM_DEFAULT; return 0; diff --git a/libcutils/socket_inaddr_any_server.c b/libcutils/socket_inaddr_any_server.c index 7d5dab4..6c849de 100644 --- a/libcutils/socket_inaddr_any_server.c +++ b/libcutils/socket_inaddr_any_server.c @@ -1,5 +1,4 @@ -/* libs/cutils/socket_inaddr_any_server.c -** +/* ** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,13 +14,11 @@ ** limitations under the License. */ -#include <cutils/sockets.h> - +#include <errno.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <errno.h> -#include <stddef.h> #ifndef HAVE_WINSOCK #include <sys/socket.h> @@ -30,13 +27,14 @@ #include <netinet/in.h> #endif +#include <cutils/sockets.h> + #define LISTEN_BACKLOG 4 /* open listen() port on any interface */ int socket_inaddr_any_server(int port, int type) { struct sockaddr_in addr; - size_t alen; int s, n; memset(&addr, 0, sizeof(addr)); @@ -48,7 +46,7 @@ int socket_inaddr_any_server(int port, int type) if(s < 0) return -1; n = 1; - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)); + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *) &n, sizeof(n)); if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { close(s); diff --git a/libcutils/socket_local_client.c b/libcutils/socket_local_client.c index 5310516..ddcc2da 100644 --- a/libcutils/socket_local_client.c +++ b/libcutils/socket_local_client.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include <cutils/sockets.h> - +#include <errno.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <errno.h> -#include <stddef.h> + +#include <cutils/sockets.h> #ifdef HAVE_WINSOCK @@ -128,7 +128,6 @@ int socket_local_client_connect(int fd, const char *name, int namespaceId, { struct sockaddr_un addr; socklen_t alen; - size_t namelen; int err; err = socket_make_sockaddr_un(name, namespaceId, &addr, &alen); diff --git a/libcutils/socket_loopback_client.c b/libcutils/socket_loopback_client.c index cb82c5e..9aed7b7 100644 --- a/libcutils/socket_loopback_client.c +++ b/libcutils/socket_loopback_client.c @@ -1,5 +1,4 @@ -/* libs/cutils/socket_loopback_client.c -** +/* ** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,13 +14,11 @@ ** limitations under the License. */ -#include <cutils/sockets.h> - +#include <errno.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <errno.h> -#include <stddef.h> #ifndef HAVE_WINSOCK #include <sys/socket.h> @@ -30,6 +27,8 @@ #include <netinet/in.h> #endif +#include <cutils/sockets.h> + /* Connect to port on the loopback IP interface. type is * SOCK_STREAM or SOCK_DGRAM. * return is a file descriptor or -1 on error @@ -37,7 +36,6 @@ int socket_loopback_client(int port, int type) { struct sockaddr_in addr; - socklen_t alen; int s; memset(&addr, 0, sizeof(addr)); diff --git a/libcutils/socket_loopback_server.c b/libcutils/socket_loopback_server.c index 3208488..71afce7 100644 --- a/libcutils/socket_loopback_server.c +++ b/libcutils/socket_loopback_server.c @@ -1,5 +1,4 @@ -/* libs/cutils/socket_loopback_server.c -** +/* ** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,13 +14,11 @@ ** limitations under the License. */ -#include <cutils/sockets.h> - +#include <errno.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <errno.h> -#include <stddef.h> #define LISTEN_BACKLOG 4 @@ -32,11 +29,12 @@ #include <netinet/in.h> #endif +#include <cutils/sockets.h> + /* open listen() port on loopback interface */ int socket_loopback_server(int port, int type) { struct sockaddr_in addr; - size_t alen; int s, n; memset(&addr, 0, sizeof(addr)); @@ -48,7 +46,7 @@ int socket_loopback_server(int port, int type) if(s < 0) return -1; n = 1; - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)); + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *) &n, sizeof(n)); if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { close(s); diff --git a/libcutils/socket_network_client.c b/libcutils/socket_network_client.c index a64006c..c52013d 100644 --- a/libcutils/socket_network_client.c +++ b/libcutils/socket_network_client.c @@ -1,5 +1,4 @@ -/* libs/cutils/socket_network_client.c -** +/* ** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,13 +14,11 @@ ** limitations under the License. */ -#include <cutils/sockets.h> - +#include <errno.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <errno.h> -#include <stddef.h> #ifndef HAVE_WINSOCK #include <sys/socket.h> @@ -31,6 +28,7 @@ #include <netdb.h> #endif +#include <cutils/sockets.h> /* Connect to port on the IP interface. type is * SOCK_STREAM or SOCK_DGRAM. @@ -40,7 +38,6 @@ int socket_network_client(const char *host, int port, int type) { struct hostent *hp; struct sockaddr_in addr; - socklen_t alen; int s; hp = gethostbyname(host); diff --git a/libcutils/sockets.c b/libcutils/sockets.c index b5a1b3d..15ede2b 100644 --- a/libcutils/sockets.c +++ b/libcutils/sockets.c @@ -14,15 +14,18 @@ * limitations under the License. */ -#include <cutils/log.h> #include <cutils/sockets.h> +#include <log/log.h> #ifdef HAVE_ANDROID_OS /* For the socket trust (credentials) check */ #include <private/android_filesystem_config.h> +#define __android_unused +#else +#define __android_unused __attribute__((__unused__)) #endif -bool socket_peer_is_trusted(int fd) +bool socket_peer_is_trusted(int fd __android_unused) { #ifdef HAVE_ANDROID_OS struct ucred cr; diff --git a/libcutils/str_parms.c b/libcutils/str_parms.c index 7cfbcb3..2e3ce9f 100644 --- a/libcutils/str_parms.c +++ b/libcutils/str_parms.c @@ -25,10 +25,9 @@ #include <string.h> #include <cutils/hashmap.h> -#include <cutils/log.h> #include <cutils/memory.h> - #include <cutils/str_parms.h> +#include <log/log.h> #define UNUSED __attribute__((unused)) @@ -194,23 +193,46 @@ err_create_str_parms: int str_parms_add_str(struct str_parms *str_parms, const char *key, const char *value) { - void *old_val; - void *tmp_key; - void *tmp_val; + void *tmp_key = NULL; + void *tmp_val = NULL; + void *old_val = NULL; + + // strdup and hashmapPut both set errno on failure. + // Set errno to 0 so we can recognize whether anything went wrong. + int saved_errno = errno; + errno = 0; tmp_key = strdup(key); + if (tmp_key == NULL) { + goto clean_up; + } + tmp_val = strdup(value); - old_val = hashmapPut(str_parms->map, tmp_key, tmp_val); + if (tmp_val == NULL) { + goto clean_up; + } - if (old_val) { - free(old_val); - free(tmp_key); - } else if (errno == ENOMEM) { - free(tmp_key); - free(tmp_val); - return -ENOMEM; + old_val = hashmapPut(str_parms->map, tmp_key, tmp_val); + if (old_val == NULL) { + // Did hashmapPut fail? + if (errno == ENOMEM) { + goto clean_up; + } + // For new keys, hashmap takes ownership of tmp_key and tmp_val. + tmp_key = tmp_val = NULL; + } else { + // For existing keys, hashmap takes ownership of tmp_val. + // (It also gives up ownership of old_val.) + tmp_val = NULL; } - return 0; + +clean_up: + free(tmp_key); + free(tmp_val); + free(old_val); + int result = -errno; + errno = saved_errno; + return result; } int str_parms_add_int(struct str_parms *str_parms, const char *key, int value) @@ -337,7 +359,6 @@ static void test_str_parms_str(const char *str) { struct str_parms *str_parms; char *out_str; - int ret; str_parms = str_parms_create_str(str); str_parms_add_str(str_parms, "dude", "woah"); @@ -352,8 +373,6 @@ static void test_str_parms_str(const char *str) int main(void) { - struct str_parms *str_parms; - test_str_parms_str(""); test_str_parms_str(";"); test_str_parms_str("="); @@ -370,6 +389,15 @@ int main(void) test_str_parms_str("foo=bar;baz=bat;"); test_str_parms_str("foo=bar;baz=bat;foo=bar"); + // hashmapPut reports errors by setting errno to ENOMEM. + // Test that we're not confused by running in an environment where this is already true. + errno = ENOMEM; + test_str_parms_str("foo=bar;baz="); + if (errno != ENOMEM) { + abort(); + } + test_str_parms_str("foo=bar;baz="); + return 0; } #endif diff --git a/libcutils/threads.c b/libcutils/threads.c index 42cc928..bf182f0 100644 --- a/libcutils/threads.c +++ b/libcutils/threads.c @@ -1,5 +1,4 @@ -/* libs/cutils/threads.c -** +/* ** Copyright (C) 2007, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,12 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ + #include <cutils/threads.h> #ifdef HAVE_PTHREADS void* thread_store_get( thread_store_t* store ) { - const pthread_key_t k = store->tls; - if (!store->has_tls) return NULL; diff --git a/libcutils/trace.c b/libcutils/trace.c index 9754a44..f57aac2 100644 --- a/libcutils/trace.c +++ b/libcutils/trace.c @@ -28,7 +28,7 @@ #include <cutils/trace.h> #define LOG_TAG "cutils-trace" -#include <cutils/log.h> +#include <log/log.h> volatile int32_t atrace_is_ready = 0; int atrace_marker_fd = -1; @@ -86,7 +86,6 @@ static bool atrace_is_cmdline_match(const char* cmdline) static bool atrace_is_app_tracing_enabled() { bool sys_debuggable = false; - bool proc_debuggable = false; char value[PROPERTY_VALUE_MAX]; bool result = false; |