diff options
author | Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org> | 2014-10-01 16:52:11 +0200 |
---|---|---|
committer | Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org> | 2014-10-01 17:57:23 +0200 |
commit | 15d9dee4aa77064669ddd4bccddaeaccd3865f21 (patch) | |
tree | b58a028f25a85199203ae5a981b05dbf93cb7fd9 /src | |
parent | a83dbae72a28c263abb7bf5374a1b41290eca00d (diff) | |
download | com-core-15d9dee4aa77064669ddd4bccddaeaccd3865f21.tar.gz com-core-15d9dee4aa77064669ddd4bccddaeaccd3865f21.tar.bz2 com-core-15d9dee4aa77064669ddd4bccddaeaccd3865f21.zip |
Revert "Keep address alignment to prevent from bus error."submit/tizen_ivi/20141007.444444submit/tizen_common/20141003.142427accepted/tizen/ivi/20141009.080623accepted/tizen/common/20141003.171248
This reverts commit 1ce8ea32c6b0943454823d642d961cd8b3e1c8f0.
This change is not compatible with 64 bits system.
In some cases, it generates a segfault in packet_create()
when allocating memory for packet->data struct with calloc.
Btw according to the reverted commit message, this commit was a consequence
of errors with GCC 4.6 that we do not use anymore.
Change-Id: I56a23552df1d84aefa83fac4d60121d2545213b7
Signed-off-by: Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/packet.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/packet.c b/src/packet.c index 2cb99f8..6057b56 100644 --- a/src/packet.c +++ b/src/packet.c @@ -224,7 +224,6 @@ static inline struct packet *packet_body_filler(struct packet *packet, int paylo { char *payload; char *str; - int align; while (*ptr) { payload = packet->data->payload + packet->data->head.payload_size; @@ -232,12 +231,7 @@ static inline struct packet *packet_body_filler(struct packet *packet, int paylo switch (*ptr) { case 'i': case 'I': - align = (unsigned long)payload & (sizeof(int) - 1); - if (align) { - align = sizeof(int) - align; - } - - packet->data->head.payload_size += sizeof(int) + align; + packet->data->head.payload_size += sizeof(int); packet->data = check_and_expand_packet(packet->data, &payload_size); if (!packet->data) { packet->state = INVALID; @@ -246,7 +240,7 @@ static inline struct packet *packet_body_filler(struct packet *packet, int paylo goto out; } - *((int *)(payload + align)) = (int)va_arg(va, int); + *((int *)payload) = (int)va_arg(va, int); break; case 's': case 'S': @@ -278,12 +272,7 @@ static inline struct packet *packet_body_filler(struct packet *packet, int paylo break; case 'd': case 'D': - align = (unsigned long)payload & (sizeof(double) - 1); - if (align) { - align = sizeof(double) - align; - } - - packet->data->head.payload_size += sizeof(double) + align; + packet->data->head.payload_size += sizeof(double); packet->data = check_and_expand_packet(packet->data, &payload_size); if (!packet->data) { packet->state = INVALID; @@ -292,7 +281,7 @@ static inline struct packet *packet_body_filler(struct packet *packet, int paylo goto out; } - *((double *)(payload + align)) = (double)va_arg(va, double); + *((double *)payload) = (double)va_arg(va, double); break; default: ErrPrint("Invalid type [%c]\n", *ptr); @@ -470,7 +459,6 @@ EAPI int packet_get(const struct packet *packet, const char *fmt, ...) int *int_ptr; double *double_ptr; char **str_ptr; - int align; if (!packet || packet->state != VALID) { return -EINVAL; @@ -484,25 +472,16 @@ EAPI int packet_get(const struct packet *packet, const char *fmt, ...) switch (*ptr) { case 'i': case 'I': - align = (unsigned long)payload & (sizeof(int) - 1); - if (align) { - align = sizeof(int) - align; - } - int_ptr = (int *)va_arg(va, int *); - *int_ptr = *((int *)(payload + align)); - offset += (sizeof(int) + align); + *int_ptr = *((int *)payload); + offset += sizeof(int); ret++; break; case 'd': case 'D': - align = (unsigned long)payload & (sizeof(double) - 1); - if (align) { - align = sizeof(double) - align; - } double_ptr = (double *)va_arg(va, double *); - *double_ptr = *((double *)(payload + align)); - offset += (sizeof(double) + align); + *double_ptr = *((double *)payload); + offset += sizeof(double); ret++; break; case 's': |