/pidgin/main: 703d7d7bdf60: Gadu-Gadu: update internal libgadu t...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Thu Apr 3 08:49:04 EDT 2014
Changeset: 703d7d7bdf60c2fa8c1d5e5c44c6a33b30098b42
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-04-03 14:48 +0200
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/703d7d7bdf60
Description:
Gadu-Gadu: update internal libgadu to fix bad-alignment warnings
diffstat:
libpurple/protocols/gg/lib/events.c | 11 +++++++----
libpurple/protocols/gg/lib/libgadu.h | 2 +-
libpurple/protocols/gg/lib/protobuf-c.c | 6 +++---
libpurple/protocols/gg/lib/sha1.c | 16 +++++++---------
4 files changed, 18 insertions(+), 17 deletions(-)
diffs (127 lines):
diff --git a/libpurple/protocols/gg/lib/events.c b/libpurple/protocols/gg/lib/events.c
--- a/libpurple/protocols/gg/lib/events.c
+++ b/libpurple/protocols/gg/lib/events.c
@@ -588,6 +588,7 @@ static gg_action_t gg_handle_resolving(s
int count = -1;
int res;
unsigned int i;
+ struct in_addr *addrs;
res = gg_resolver_recv(sess->fd, buf, sizeof(buf));
@@ -622,8 +623,10 @@ static gg_action_t gg_handle_resolving(s
/* Sprawdź, czy mamy listÄ zakoÅczonÄ
INADDR_NONE */
+ addrs = (struct in_addr *)(void *)sess->recv_buf;
+
for (i = 0; i < sess->recv_done / sizeof(struct in_addr); i++) {
- if (((struct in_addr*) sess->recv_buf)[i].s_addr == INADDR_NONE) {
+ if (addrs[i].s_addr == INADDR_NONE) {
count = i;
break;
}
@@ -661,7 +664,7 @@ static gg_action_t gg_handle_resolving(s
if (i > 0)
len += 2;
- len += strlen(inet_ntoa(((struct in_addr*) sess->recv_buf)[i]));
+ len += strlen(inet_ntoa(addrs[i]));
}
list = malloc(len + 1);
@@ -675,7 +678,7 @@ static gg_action_t gg_handle_resolving(s
if (i > 0)
strcat(list, ", ");
- strcat(list, inet_ntoa(((struct in_addr*) sess->recv_buf)[i]));
+ strcat(list, inet_ntoa(addrs[i]));
}
gg_debug_session(sess, GG_DEBUG_DUMP, "// gg_watch_fd() resolved: %s\n", list);
@@ -687,7 +690,7 @@ static gg_action_t gg_handle_resolving(s
gg_close(sess);
sess->state = next_state;
- sess->resolver_result = (struct in_addr*) sess->recv_buf;
+ sess->resolver_result = addrs;
sess->resolver_count = count;
sess->resolver_index = 0;
sess->recv_buf = NULL;
diff --git a/libpurple/protocols/gg/lib/libgadu.h b/libpurple/protocols/gg/lib/libgadu.h
--- a/libpurple/protocols/gg/lib/libgadu.h
+++ b/libpurple/protocols/gg/lib/libgadu.h
@@ -283,7 +283,7 @@ struct gg_session {
int initial_status; /**< PoczÄ
tkowy status */
int status; /**< Aktualny status */
- char *recv_buf; /**< Bufor na odbierany pakiety */
+ char *recv_buf; /**< Bufor na odbierane pakiety. Wskaźnik zawsze maksymalnie wyrównany, tak jak w wyniku dziaÅania \c malloc(). */
int recv_done; /**< Liczba wczytanych bajtów pakietu */
int recv_left; /**< Liczba pozostaÅych do wczytania bajtów pakietu */
diff --git a/libpurple/protocols/gg/lib/protobuf-c.c b/libpurple/protocols/gg/lib/protobuf-c.c
--- a/libpurple/protocols/gg/lib/protobuf-c.c
+++ b/libpurple/protocols/gg/lib/protobuf-c.c
@@ -919,7 +919,7 @@ repeated_field_pack (const ProtobufCFiel
const void *member,
uint8_t *out)
{
- char *array = * (char * const *) member;
+ void *array = * (char * const *) member;
unsigned i;
if (field->packed)
{
@@ -1024,7 +1024,7 @@ repeated_field_pack (const ProtobufCFiel
for (i = 0; i < count; i++)
{
rv += required_field_pack (field, array, out + rv);
- array += siz;
+ array = ((char*)array) + siz;
}
return rv;
}
@@ -1902,7 +1902,7 @@ parse_packed_repeated_member (ScannedMem
const ProtobufCFieldDescriptor *field = scanned_member->field;
size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
size_t siz = sizeof_elt_in_repeated_array (field->type);
- char *array = *(char**)member + siz * (*p_n);
+ void *array = *(char**)member + siz * (*p_n);
const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len;
size_t rem = scanned_member->len - scanned_member->length_prefix_len;
size_t count = 0;
diff --git a/libpurple/protocols/gg/lib/sha1.c b/libpurple/protocols/gg/lib/sha1.c
--- a/libpurple/protocols/gg/lib/sha1.c
+++ b/libpurple/protocols/gg/lib/sha1.c
@@ -88,13 +88,13 @@ static int SHA1_Final(unsigned char dige
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
#ifndef GG_CONFIG_BIGENDIAN
-#define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) \
- |(rol(block->l[i], 8) & 0x00FF00FF))
+#define blk0(i) (block.l[i] = (rol(block.l[i], 24) & 0xFF00FF00) \
+ |(rol(block.l[i], 8) & 0x00FF00FF))
#else
-#define blk0(i) block->l[i]
+#define blk0(i) block.l[i]
#endif
-#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
- ^block->l[(i+2)&15]^block->l[i&15], 1))
+#define blk(i) (block.l[i&15] = rol(block.l[(i+13)&15]^block.l[(i+8)&15] \
+ ^block.l[(i+2)&15]^block.l[i&15], 1))
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
/* style:comma:start-ignore */
@@ -115,10 +115,8 @@ typedef union {
unsigned char c[64];
uint32_t l[16];
} CHAR64LONG16;
-CHAR64LONG16* block;
-static unsigned char workspace[64];
- block = (CHAR64LONG16*)workspace;
- memcpy(block, buffer, 64);
+ CHAR64LONG16 block;
+ memcpy(&block, buffer, sizeof(block));
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
More information about the Commits
mailing list