Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 826d75fb authored by Bernhard Rosenkraenzer's avatar Bernhard Rosenkraenzer Committed by Ricardo Cerqueira
Browse files

libcutils: Fix aliasing violations



Fix aliasing violtations that caused a need for the
code to be compiled with -fno-strict-aliasing

Signed-off-by: default avatarBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>

libnetutils: Fix aliasing violations

This allows us to build it with more compiler optimizations

Signed-off-by: default avatarBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>

libcutils: Fix aliasing violation

Signed-off-by: default avatarBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>

core: Fix build in ISO C++11 mode

Fix compatibility with ISO C++11 compilers

Signed-off-by: default avatarBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
Change-Id: I8f9aa775b5681d4d8c5202a1a1935acb4efa4171

adb: Don't force -O2

Don't force -O2 over -O3 -- the O2 hardcode is there to force
optimizations, not to reduce them...

Change-Id: Ic75eeb767db4926f519580fba8f5f7b8e593df4f
Signed-off-by: default avatarBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
parent 3853a7c0
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -72,7 +72,16 @@ else
  LOCAL_SRC_FILES += fdevent.c
endif

LOCAL_CFLAGS += -O2 -g -DADB_HOST=1  -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -g -DADB_HOST=1  -Wall -Wno-unused-parameter
# adb can't be built without optimizations, so we enforce -O2 if no
# other optimization flag is set - but we don't override what the global
# flags are saying if something else is given (-Os or -O3 are useful)
ifeq ($(findstring -O, $(HOST_GLOBAL_CFLAGS)),)
LOCAL_CFLAGS += -O2
endif
ifneq ($(findstring -O0, $(HOST_GLOBAL_CFLAGS)),)
LOCAL_CFLAGS += -O2
endif
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
LOCAL_MODULE := adb

@@ -114,7 +123,16 @@ LOCAL_SRC_FILES := \
	log_service.c \
	utils.c

LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
LOCAL_CFLAGS := -g -DADB_HOST=0 -Wall -Wno-unused-parameter
# adb can't be built without optimizations, so we enforce -O2 if no
# other optimization flag is set - but we don't override what the global
# flags are saying if something else is given (-Os or -O3 are useful)
ifeq ($(findstring -O, $(TARGET_GLOBAL_CFLAGS)),)
LOCAL_CFLAGS += -O2
endif
ifneq ($(findstring -O0, $(TARGET_GLOBAL_CFLAGS)),)
LOCAL_CFLAGS += -O2
endif
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE

ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
@@ -160,7 +178,6 @@ LOCAL_SRC_FILES := \
	fdevent.c

LOCAL_CFLAGS := \
	-O2 \
	-g \
	-DADB_HOST=1 \
	-DADB_HOST_ON_TARGET=1 \
@@ -169,6 +186,16 @@ LOCAL_CFLAGS := \
	-D_XOPEN_SOURCE \
	-D_GNU_SOURCE

# adb can't be built without optimizations, so we enforce -O2 if no
# other optimization flag is set - but we don't override what the global
# flags are saying if something else is given (-Os or -O3 are useful)
ifeq ($(findstring -O, $(TARGET_GLOBAL_CFLAGS)),)
LOCAL_CFLAGS += -O2
endif
ifneq ($(findstring -O0, $(TARGET_GLOBAL_CFLAGS)),)
LOCAL_CFLAGS += -O2
endif

LOCAL_MODULE := adb

LOCAL_STATIC_LIBRARIES := libzipfile libunz libcutils
+2 −0
Original line number Diff line number Diff line
@@ -24,7 +24,9 @@
extern "C" {
#endif

#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__)
typedef uint16_t char16_t;
#endif

extern char * strndup16to8 (const char16_t* s, size_t n);
extern size_t strnlen16to8 (const char16_t* s, size_t n);
+7 −4
Original line number Diff line number Diff line
@@ -100,7 +100,10 @@ static int connectToServer(const char* fileName)
    int sock = -1;
    int cc;

    struct sockaddr_un addr;
    union {
        struct sockaddr_un un;
        struct sockaddr generic;
    } addr;
    
    sock = socket(AF_UNIX, SOCK_STREAM, 0);
    if (sock < 0) {
@@ -109,9 +112,9 @@ static int connectToServer(const char* fileName)
    }

    /* connect to socket; fails if file doesn't exist */
    strcpy(addr.sun_path, fileName);    // max 108 bytes
    addr.sun_family = AF_UNIX;
    cc = connect(sock, (struct sockaddr*) &addr, SUN_LEN(&addr));
    strcpy(addr.un.sun_path, fileName);    // max 108 bytes
    addr.un.sun_family = AF_UNIX;
    cc = connect(sock, &addr.generic, SUN_LEN(&addr.un));
    if (cc < 0) {
        // ENOENT means socket file doesn't exist
        // ECONNREFUSED means socket exists but nobody is listening
+8 −5
Original line number Diff line number Diff line
@@ -35,14 +35,17 @@
/* open listen() port on any interface */
int socket_inaddr_any_server(int port, int type)
{
    struct sockaddr_in addr;
    union {
        struct sockaddr_in in;
        struct sockaddr generic;
    } addr;
    size_t alen;
    int s, n;

    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(port);
    addr.sin_addr.s_addr = htonl(INADDR_ANY);
    addr.in.sin_family = AF_INET;
    addr.in.sin_port = htons(port);
    addr.in.sin_addr.s_addr = htonl(INADDR_ANY);

    s = socket(AF_INET, type, 0);
    if(s < 0) return -1;
@@ -50,7 +53,7 @@ int socket_inaddr_any_server(int port, int type)
    n = 1;
    setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n));

    if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
    if(bind(s, &addr.generic, sizeof(addr.in)) < 0) {
        close(s);
        return -1;
    }
+6 −3
Original line number Diff line number Diff line
@@ -124,18 +124,21 @@ error:
int socket_local_client_connect(int fd, const char *name, int namespaceId, 
        int type)
{
    struct sockaddr_un addr;
    union {
        struct sockaddr_un un;
        struct sockaddr generic;
    } addr;
    socklen_t alen;
    size_t namelen;
    int err;

    err = socket_make_sockaddr_un(name, namespaceId, &addr, &alen);
    err = socket_make_sockaddr_un(name, namespaceId, &addr.un, &alen);

    if (err < 0) {
        goto error;
    }

    if(connect(fd, (struct sockaddr *) &addr, alen) < 0) {
    if(connect(fd, &addr.generic, alen) < 0) {
        goto error;
    }

Loading