Merge "libcutils: turn on -Werror"

This commit is contained in:
Mark Salyzyn 2014-05-02 17:03:47 +00:00 committed by Gerrit Code Review
commit a32e01d2f4
18 changed files with 99 additions and 106 deletions

View File

@ -77,7 +77,7 @@ LOCAL_MODULE := libcutils
LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c
LOCAL_LDLIBS := -lpthread
LOCAL_STATIC_LIBRARIES := liblog
LOCAL_CFLAGS += $(hostSmpFlag)
LOCAL_CFLAGS += $(hostSmpFlag) -Werror
include $(BUILD_HOST_STATIC_LIBRARY)
@ -88,14 +88,14 @@ LOCAL_MODULE := lib64cutils
LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c
LOCAL_LDLIBS := -lpthread
LOCAL_STATIC_LIBRARIES := lib64log
LOCAL_CFLAGS += $(hostSmpFlag) -m64
LOCAL_CFLAGS += $(hostSmpFlag) -m64 -Werror
include $(BUILD_HOST_STATIC_LIBRARY)
# Tests for host
# ========================================================
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_STATIC_LIBRARIES := liblog
LOCAL_MODULE_TAGS := optional
@ -135,7 +135,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)
@ -144,13 +144,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

View File

@ -19,20 +19,22 @@
* 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 <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <cutils/ashmem.h>
int ashmem_create_region(const char *ignored, size_t size)
#define __unused __attribute__((__unused__))
int ashmem_create_region(const char *ignored __unused, size_t size)
{
static const char txt[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@ -78,17 +80,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;
}

View File

@ -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");

View File

@ -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;

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.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;

View File

@ -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;

View File

@ -14,25 +14,27 @@
* limitations under the License.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#if defined(HAVE_PRCTL)
#include <sys/prctl.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <cutils/process_name.h>
#ifdef HAVE_ANDROID_OS
#include <cutils/properties.h>
#endif
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#if defined(HAVE_PRCTL)
#include <sys/prctl.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

View File

@ -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";

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.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;

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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));

View File

@ -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);

View File

@ -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;

View File

@ -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))
@ -374,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("=");

View File

@ -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;

View File

@ -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;