diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2011-12-07 14:06:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@betelgeuse.canonical.com> | 2011-12-07 14:06:51 +0000 |
commit | 0826d0465ec54b12bd0fe65cf4fa5ee20816e915 (patch) | |
tree | 4f5fd8f1d1082b54455d5cf0f67f1fa3b6d96d88 | |
parent | ff5356497da16cecbd511303844b935b4a98dd55 (diff) | |
parent | 12ce8cdadcbfd92f5bd7c9c97b3d70d7f1289fdb (diff) | |
download | base-0826d0465ec54b12bd0fe65cf4fa5ee20816e915.tar.gz |
Merge "frameworks/base: Fix aliasing violations" into linaro_android_4.0.1
-rw-r--r-- | libs/utils/ResourceTypes.cpp | 2 | ||||
-rw-r--r-- | media/libmedia/Visualizer.cpp | 31 | ||||
-rw-r--r-- | opengl/libs/EGL/Loader.cpp | 6 | ||||
-rw-r--r-- | opengl/libs/GLES2_dbg/src/server.cpp | 15 |
4 files changed, 36 insertions, 18 deletions
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index 6cf01c8d6887..37c98747d4ed 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -3130,7 +3130,7 @@ bool ResTable::stringToFloat(const char16_t* s, size_t len, Res_value* outValue) if (*end == 0) { if (outValue) { outValue->dataType = outValue->TYPE_FLOAT; - *(float*)(&outValue->data) = f; + memcpy(&outValue->data, &f, sizeof(float)); return true; } } diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp index bf404819107d..6ea5a59d61da 100644 --- a/media/libmedia/Visualizer.cpp +++ b/media/libmedia/Visualizer.cpp @@ -138,13 +138,17 @@ status_t Visualizer::setCaptureSize(uint32_t size) return INVALID_OPERATION; } - uint32_t buf32[sizeof(effect_param_t) / sizeof(uint32_t) + 2]; - effect_param_t *p = (effect_param_t *)buf32; + union { + uint32_t buf32[sizeof(effect_param_t) / sizeof(uint32_t) + 2]; + effect_param_t bufp; + }; + effect_param_t *p = &bufp; p->psize = sizeof(uint32_t); p->vsize = sizeof(uint32_t); - *(int32_t *)p->data = VISUALIZER_PARAM_CAPTURE_SIZE; - *((int32_t *)p->data + 1)= size; + int32_t const vpcs = VISUALIZER_PARAM_CAPTURE_SIZE; + memcpy(&p->data, &vpcs, sizeof(vpcs)); + memcpy(&p->data+sizeof(int32_t), &size, sizeof(size)); status_t status = setParameter(p); LOGV("setCaptureSize size %d status %d p->status %d", size, status, p->status); @@ -271,21 +275,24 @@ void Visualizer::periodicCapture() uint32_t Visualizer::initCaptureSize() { - uint32_t buf32[sizeof(effect_param_t) / sizeof(uint32_t) + 2]; - effect_param_t *p = (effect_param_t *)buf32; + union { + uint32_t buf32[sizeof(effect_param_t) / sizeof(uint32_t) + 2]; + effect_param_t p; + }; - p->psize = sizeof(uint32_t); - p->vsize = sizeof(uint32_t); - *(int32_t *)p->data = VISUALIZER_PARAM_CAPTURE_SIZE; - status_t status = getParameter(p); + p.psize = sizeof(uint32_t); + p.vsize = sizeof(uint32_t); + int32_t const vpcs = VISUALIZER_PARAM_CAPTURE_SIZE; + memcpy(&p.data, &vpcs, sizeof(vpcs)); + status_t status = getParameter(&p); if (status == NO_ERROR) { - status = p->status; + status = p.status; } uint32_t size = 0; if (status == NO_ERROR) { - size = *((int32_t *)p->data + 1); + memcpy(&size, &p.data+sizeof(int32_t), sizeof(int32_t)); } mCaptureSize = size; diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index 325193c7f44b..70eac548ce3e 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -311,16 +311,18 @@ void *Loader::load_driver(const char* kind, const char *tag, } if (mask & GLESv1_CM) { + void *gl=&cnx->hooks[GLESv1_INDEX]->gl; init_api(dso, gl_names, (__eglMustCastToProperFunctionPointerType*) - &cnx->hooks[GLESv1_INDEX]->gl, + gl, getProcAddress); } if (mask & GLESv2) { + void *gl=&cnx->hooks[GLESv2_INDEX]->gl; init_api(dso, gl_names, (__eglMustCastToProperFunctionPointerType*) - &cnx->hooks[GLESv2_INDEX]->gl, + gl, getProcAddress); } diff --git a/opengl/libs/GLES2_dbg/src/server.cpp b/opengl/libs/GLES2_dbg/src/server.cpp index 0c711bf200fe..80a2d08101a0 100644 --- a/opengl/libs/GLES2_dbg/src/server.cpp +++ b/opengl/libs/GLES2_dbg/src/server.cpp @@ -49,7 +49,16 @@ void StartDebugServer(const unsigned short port, const bool forceUseFile, return; LOGD("GLESv2_dbg: StartDebugServer create socket"); - struct sockaddr_in server = {}, client = {}; + union { + sockaddr_in server; + sockaddr server_generic; + }; + union { + sockaddr_in client; + sockaddr client_generic; + }; + server = {}; + client = {}; /* Create the TCP socket */ if (forceUseFile || (serverSock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { @@ -66,7 +75,7 @@ void StartDebugServer(const unsigned short port, const bool forceUseFile, /* Bind the server socket */ socklen_t sizeofSockaddr_in = sizeof(sockaddr_in); - if (bind(serverSock, (struct sockaddr *) &server, + if (bind(serverSock, &server_generic, sizeof(server)) < 0) { Die("Failed to bind the server socket"); } @@ -80,7 +89,7 @@ void StartDebugServer(const unsigned short port, const bool forceUseFile, /* Wait for client connection */ if ((clientSock = - accept(serverSock, (struct sockaddr *) &client, + accept(serverSock, &client_generic, &sizeofSockaddr_in)) < 0) { Die("Failed to accept client connection"); } |