diff options
author | Zach Pfeffer <zach.pfeffer@linaro.org> | 2011-12-15 17:58:40 +0000 |
---|---|---|
committer | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-03-29 09:41:12 +0200 |
commit | 634a905618c37b153a06559433f31ab2a10a920d (patch) | |
tree | ce2ff90a38331238152f870e1752c235f192bb80 | |
parent | 2f7eb7ad83bd0cb56bee82fddf56f327f37f3dc9 (diff) | |
download | base-634a905618c37b153a06559433f31ab2a10a920d.tar.gz |
Revert "frameworks/base: Fix various aliasing violations"
This reverts commit e494389d542f755a11a3dab66167efe547170f92
-rw-r--r-- | core/jni/Android.mk | 1 | ||||
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 9 | ||||
-rw-r--r-- | libs/hwui/ShapeCache.h | 34 | ||||
-rw-r--r-- | libs/hwui/TextDropShadowCache.h | 4 | ||||
-rw-r--r-- | media/libstagefright/codecs/avc/enc/src/motion_comp.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 5 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPConnection.cpp | 23 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTSPConnection.cpp | 7 | ||||
-rw-r--r-- | media/libstagefright/rtsp/MyHandler.h | 16 |
9 files changed, 38 insertions, 69 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index d14253d3b616..71c5d2662292 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -4,7 +4,6 @@ include $(CLEAR_VARS) LOCAL_CFLAGS += -DHAVE_CONFIG_H -DKHTML_NO_EXCEPTIONS -DGKWQ_NO_JAVA LOCAL_CFLAGS += -DNO_SUPPORT_JS_BINDING -DQT_NO_WHEELEVENT -DKHTML_NO_XBL LOCAL_CFLAGS += -U__APPLE__ -LOCAL_CFLAGS += -fno-strict-aliasing ifeq ($(TARGET_ARCH), arm) LOCAL_CFLAGS += -DPACKED="__attribute__ ((packed))" diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 49c25f673fa7..158f78503689 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -692,15 +692,12 @@ void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) { } const float skewX = paint->getTextSkewX(); - uint32_t italicStyle; - memcpy(&italicStyle, &skewX, sizeof(italicStyle)); + uint32_t italicStyle = *(uint32_t*) &skewX; const float scaleXFloat = paint->getTextScaleX(); - uint32_t scaleX; - memcpy(&scaleX, &scaleXFloat, sizeof(scaleX)); + uint32_t scaleX = *(uint32_t*) &scaleXFloat; SkPaint::Style style = paint->getStyle(); const float strokeWidthFloat = paint->getStrokeWidth(); - uint32_t strokeWidth; - memcpy(&strokeWidth, &strokeWidthFloat, sizeof(strokeWidth)); + uint32_t strokeWidth = *(uint32_t*) &strokeWidthFloat; mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle, scaleX, style, strokeWidth); diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h index 0b37828f8dee..0660b690a1cd 100644 --- a/libs/hwui/ShapeCache.h +++ b/libs/hwui/ShapeCache.h @@ -90,9 +90,9 @@ struct ShapeCacheEntry { cap = SkPaint::kDefault_Cap; style = SkPaint::kFill_Style; float v = 4.0f; - memcpy(&miter, &v, sizeof(miter)); + miter = *(uint32_t*) &v; v = 1.0f; - memcpy(&strokeWidth, &v, sizeof(strokeWidth)); + strokeWidth = *(uint32_t*) &v; pathEffect = NULL; } @@ -101,9 +101,9 @@ struct ShapeCacheEntry { join = paint->getStrokeJoin(); cap = paint->getStrokeCap(); float v = paint->getStrokeMiter(); - memcpy(&miter, &v, sizeof(miter)); + miter = *(uint32_t*) &v; v = paint->getStrokeWidth(); - memcpy(&strokeWidth, &v, sizeof(strokeWidth)); + strokeWidth = *(uint32_t*) &v; style = paint->getStyle(); pathEffect = paint->getPathEffect(); } @@ -148,10 +148,10 @@ protected: struct RoundRectShapeCacheEntry: public ShapeCacheEntry { RoundRectShapeCacheEntry(float width, float height, float rx, float ry, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeRoundRect, paint) { - memcpy(&mWidth, &width, sizeof(mWidth)); - memcpy(&mHeight, &height, sizeof(mHeight)); - memcpy(&mRx, &rx, sizeof(mRx)); - memcpy(&mRy, &ry, sizeof(mRy)); + mWidth = *(uint32_t*) &width; + mHeight = *(uint32_t*) &height; + mRx = *(uint32_t*) ℞ + mRy = *(uint32_t*) &ry; } RoundRectShapeCacheEntry(): ShapeCacheEntry() { @@ -185,7 +185,7 @@ private: struct CircleShapeCacheEntry: public ShapeCacheEntry { CircleShapeCacheEntry(float radius, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeCircle, paint) { - memcpy(&mRadius, &radius, sizeof(mRadius)); + mRadius = *(uint32_t*) &radius; } CircleShapeCacheEntry(): ShapeCacheEntry() { @@ -207,8 +207,8 @@ private: struct OvalShapeCacheEntry: public ShapeCacheEntry { OvalShapeCacheEntry(float width, float height, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeOval, paint) { - memcpy(&mWidth, &width, sizeof(mWidth)); - memcpy(&mHeight, &height, sizeof(mHeight)); + mWidth = *(uint32_t*) &width; + mHeight = *(uint32_t*) &height; } OvalShapeCacheEntry(): ShapeCacheEntry() { @@ -233,8 +233,8 @@ private: struct RectShapeCacheEntry: public ShapeCacheEntry { RectShapeCacheEntry(float width, float height, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeRect, paint) { - memcpy(&mWidth, &width, sizeof(mWidth)); - memcpy(&mHeight, &height, sizeof(mHeight)); + mWidth = *(uint32_t*) &width; + mHeight = *(uint32_t*) &height; } RectShapeCacheEntry(): ShapeCacheEntry() { @@ -260,10 +260,10 @@ struct ArcShapeCacheEntry: public ShapeCacheEntry { ArcShapeCacheEntry(float width, float height, float startAngle, float sweepAngle, bool useCenter, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeArc, paint) { - memcpy(&mWidth, &width, sizeof(mWidth)); - memcpy(&mHeight, &height, sizeof(mHeight)); - memcpy(&mStartAngle, &startAngle, sizeof(mStartAngle)); - memcpy(&mSweepAngle, &sweepAngle, sizeof(mSweepAngle)); + mWidth = *(uint32_t*) &width; + mHeight = *(uint32_t*) &height; + mStartAngle = *(uint32_t*) &startAngle; + mSweepAngle = *(uint32_t*) &sweepAngle; mUseCenter = useCenter ? 1 : 0; } diff --git a/libs/hwui/TextDropShadowCache.h b/libs/hwui/TextDropShadowCache.h index 35eb4cc9f571..e2bdde1eca89 100644 --- a/libs/hwui/TextDropShadowCache.h +++ b/libs/hwui/TextDropShadowCache.h @@ -49,10 +49,10 @@ struct ShadowText { } const float skewX = paint->getTextSkewX(); - memcpy(&italicStyle, &skewX, sizeof(italicStyle)); + italicStyle = *(uint32_t*) &skewX; const float scaleXFloat = paint->getTextScaleX(); - memcpy(&scaleX, &scaleXFloat, sizeof(scaleX)); + scaleX = *(uint32_t*) &scaleXFloat; } ~ShadowText() { diff --git a/media/libstagefright/codecs/avc/enc/src/motion_comp.cpp b/media/libstagefright/codecs/avc/enc/src/motion_comp.cpp index fff65ebab0dc..ac62d782c83d 100644 --- a/media/libstagefright/codecs/avc/enc/src/motion_comp.cpp +++ b/media/libstagefright/codecs/avc/enc/src/motion_comp.cpp @@ -1315,11 +1315,7 @@ void eDiagonalInterpMC(uint8 *in1, uint8 *in2, int inpitch, int result; uint8 *p_cur, *p_ref, *p_tmp8; int curr_offset, ref_offset; - union { - uint8 tmp_res[24][24]; - uint32 tmp_res32[24][24/4]; - }; - uint8 tmp_in[24][24]; + uint8 tmp_res[24][24], tmp_in[24][24]; uint32 *p_tmp; uint32 tmp, pkres, tmp_result; int32 r0, r1, r2, r3, r4, r5; @@ -1337,7 +1333,7 @@ void eDiagonalInterpMC(uint8 *in1, uint8 *in2, int inpitch, ref_offset = 24-blkwidth; }*/ - p_tmp = & (tmp_res32[0][0]); + p_tmp = (uint32*) & (tmp_res[0][0]); for (j = blkheight; j > 0; j--) { r13 = 0; diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index a13ee0b35a0e..f67cdace819c 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -192,9 +192,8 @@ void LiveSession::onConnect(const sp<AMessage> &msg) { sp<AMessage> meta; playlist->itemAt(i, &item.mURI, &meta); - int32_t bandwidth; - CHECK(meta->findInt32("bandwidth", &bandwidth)); - item.mBandwidth = bandwidth; + unsigned long bandwidth; + CHECK(meta->findInt32("bandwidth", (int32_t *)&item.mBandwidth)); mBandwidthItems.push(item); } diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp index 738d1d7376a9..cd374e2a2017 100644 --- a/media/libstagefright/rtsp/ARTPConnection.cpp +++ b/media/libstagefright/rtsp/ARTPConnection.cpp @@ -120,24 +120,21 @@ void ARTPConnection::MakePortPair( start &= ~1; for (unsigned port = start; port < 65536; port += 2) { - union { - struct sockaddr_in addr; - struct sockaddr addr_generic; - }; + struct sockaddr_in addr; memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons(port); if (bind(*rtpSocket, - &addr_generic, sizeof(addr)) < 0) { + (const struct sockaddr *)&addr, sizeof(addr)) < 0) { continue; } addr.sin_port = htons(port + 1); if (bind(*rtcpSocket, - &addr_generic, sizeof(addr)) == 0) { + (const struct sockaddr *)&addr, sizeof(addr)) == 0) { *rtpPort = port; return; } @@ -343,14 +340,9 @@ void ARTPConnection::onPollStreams() { ssize_t n; do { - union { - sockaddr_in *sa_in; - sockaddr *sa; - }; - sa_in = &s->mRemoteRTCPAddr; n = sendto( s->mRTCPSocket, buffer->data(), buffer->size(), 0, - sa, + (const struct sockaddr *)&s->mRemoteRTCPAddr, sizeof(s->mRemoteRTCPAddr)); } while (n < 0 && errno == EINTR); @@ -389,17 +381,12 @@ status_t ARTPConnection::receive(StreamInfo *s, bool receiveRTP) { ssize_t nbytes; do { - union { - sockaddr_in *sa_in; - sockaddr *sa; - }; - sa_in = &s->mRemoteRTCPAddr; nbytes = recvfrom( receiveRTP ? s->mRTPSocket : s->mRTCPSocket, buffer->data(), buffer->capacity(), 0, - remoteAddrLen > 0 ? sa : NULL, + remoteAddrLen > 0 ? (struct sockaddr *)&s->mRemoteRTCPAddr : NULL, remoteAddrLen > 0 ? &remoteAddrLen : NULL); } while (nbytes < 0 && errno == EINTR); diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp index 353eb08a527e..380b3dcdcf9a 100644 --- a/media/libstagefright/rtsp/ARTSPConnection.cpp +++ b/media/libstagefright/rtsp/ARTSPConnection.cpp @@ -268,17 +268,14 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) { MakeSocketBlocking(mSocket, false); - union { - struct sockaddr_in remote; - struct sockaddr remote_generic; - }; + struct sockaddr_in remote; memset(remote.sin_zero, 0, sizeof(remote.sin_zero)); remote.sin_family = AF_INET; remote.sin_addr.s_addr = *(in_addr_t *)ent->h_addr; remote.sin_port = htons(port); int err = ::connect( - mSocket, &remote_generic, sizeof(remote)); + mSocket, (const struct sockaddr *)&remote, sizeof(remote)); reply->setInt32("server-ip", ntohl(remote.sin_addr.s_addr)); diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index 388d5d994d38..5a95f9cfc35c 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -197,12 +197,9 @@ struct MyHandler : public AHandler { } static void addSDES(int s, const sp<ABuffer> &buffer) { - union { - struct sockaddr_in addr; - struct sockaddr addr_generic; - }; + struct sockaddr_in addr; socklen_t addrSize = sizeof(addr); - CHECK_EQ(0, getsockname(s, &addr_generic, &addrSize)); + CHECK_EQ(0, getsockname(s, (sockaddr *)&addr, &addrSize)); uint8_t *data = buffer->data() + buffer->size(); data[0] = 0x80 | 1; @@ -258,10 +255,7 @@ struct MyHandler : public AHandler { // rtp/rtcp ports to poke a hole into the firewall for future incoming // packets. We're going to send an RR/SDES RTCP packet to both of them. bool pokeAHole(int rtpSocket, int rtcpSocket, const AString &transport) { - union { - struct sockaddr_in addr; - struct sockaddr addr_generic; - }; + struct sockaddr_in addr; memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); addr.sin_family = AF_INET; @@ -330,7 +324,7 @@ struct MyHandler : public AHandler { ssize_t n = sendto( rtpSocket, buf->data(), buf->size(), 0, - &addr_generic, sizeof(addr)); + (const sockaddr *)&addr, sizeof(addr)); if (n < (ssize_t)buf->size()) { LOGE("failed to poke a hole for RTP packets"); @@ -341,7 +335,7 @@ struct MyHandler : public AHandler { n = sendto( rtcpSocket, buf->data(), buf->size(), 0, - &addr_generic, sizeof(addr)); + (const sockaddr *)&addr, sizeof(addr)); if (n < (ssize_t)buf->size()) { LOGE("failed to poke a hole for RTCP packets"); |