# HG changeset patch # User Richard Laager # Date 1182042705 0 # Node ID 833f7cbe4f12babc8c2615343f9264fbb33dcae8 # Parent 00cec200ec589aeb1f6287ebdc3d1f60ef2eeabf A patch from o_sukhodolsky to fix a compiler warning in the QQ code. I've modified this patch so it actually compiles, then used the new function to fix the other warning in the same file. Fixes #1566 References #1344 diff -r 00cec200ec58 -r 833f7cbe4f12 libpurple/protocols/qq/group_im.c --- a/libpurple/protocols/qq/group_im.c Sun Jun 17 00:19:12 2007 +0000 +++ b/libpurple/protocols/qq/group_im.c Sun Jun 17 01:11:45 2007 +0000 @@ -341,7 +341,7 @@ read_packet_dw(data, cursor, data_len, &(im_group->member_uid)); read_packet_w(data, cursor, data_len, &unknown); /* 0x0001? */ read_packet_w(data, cursor, data_len, &(im_group->msg_seq)); - read_packet_dw(data, cursor, data_len, (guint32 *) & (im_group->send_time)); + read_packet_time(data, cursor, data_len, &im_group->send_time); read_packet_dw(data, cursor, data_len, &unknown4); /* versionID */ /* * length includes font_attr diff -r 00cec200ec58 -r 833f7cbe4f12 libpurple/protocols/qq/login_logout.c --- a/libpurple/protocols/qq/login_logout.c Sun Jun 17 00:19:12 2007 +0000 +++ b/libpurple/protocols/qq/login_logout.c Sun Jun 17 01:11:45 2007 +0000 @@ -181,7 +181,7 @@ /* 031-032: server listening port */ bytes += read_packet_w(data, &cursor, len, &lrop.server_port); /* 033-036: login time for current session */ - bytes += read_packet_dw(data, &cursor, len, (guint32 *) &lrop.login_time); + bytes += read_packet_time(data, &cursor, len, &lrop.login_time); /* 037-062: 26 bytes, unknown */ bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown1, 26); /* 063-066: unknown server1 ip address */ @@ -203,7 +203,7 @@ /* 123-126: login IP of last session */ bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.last_client_ip, 4); /* 127-130: login time of last session */ - bytes += read_packet_dw(data, &cursor, len, (guint32 *) &lrop.last_login_time); + bytes += read_packet_time(data, &cursor, len, &lrop.last_login_time); /* 131-138: 8 bytes unknown */ bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown6, 8); diff -r 00cec200ec58 -r 833f7cbe4f12 libpurple/protocols/qq/packet_parse.c --- a/libpurple/protocols/qq/packet_parse.c Sun Jun 17 00:19:12 2007 +0000 +++ b/libpurple/protocols/qq/packet_parse.c Sun Jun 17 01:11:45 2007 +0000 @@ -65,6 +65,19 @@ } } +/* read four bytes as "time_t" from buf, + * return the number of bytes read if succeeds, otherwise return -1 + * This function is a wrapper around read_packet_dw() to avoid casting. */ +gint read_packet_time(guint8 *buf, guint8 **cursor, gint buflen, time_t *t) +{ + guint32 time; + gint ret = read_packet_dw(buf, cursor, buflen, &time); + if (ret != -1 ) { + *t = time; + } + return ret; +} + /* read datalen bytes from buf, * return the number of bytes read if succeeds, otherwise return -1 */ gint read_packet_data(guint8 *buf, guint8 **cursor, gint buflen, guint8 *data, gint datalen) { diff -r 00cec200ec58 -r 833f7cbe4f12 libpurple/protocols/qq/packet_parse.h --- a/libpurple/protocols/qq/packet_parse.h Sun Jun 17 00:19:12 2007 +0000 +++ b/libpurple/protocols/qq/packet_parse.h Sun Jun 17 01:11:45 2007 +0000 @@ -39,6 +39,7 @@ gint read_packet_b(guint8 *buf, guint8 **cursor, gint buflen, guint8 *b); gint read_packet_w(guint8 *buf, guint8 **cursor, gint buflen, guint16 *w); gint read_packet_dw(guint8 *buf, guint8 **cursor, gint buflen, guint32 *dw); +gint read_packet_time(guint8 *buf, guint8 **cursor, gint buflen, time_t *t); gint read_packet_data(guint8 *buf, guint8 **cursor, gint buflen, guint8 *data, gint datalen); gint create_packet_b(guint8 *buf, guint8 **cursor, guint8 b); gint create_packet_w(guint8 *buf, guint8 **cursor, guint16 w);