pidgin: 74e05701: Change the "length of bstream" data type...

markdoliner at pidgin.im markdoliner at pidgin.im
Sun Aug 15 04:45:51 EDT 2010


----------------------------------------------------------------------
Revision: 74e057012b58f5f94a09d304a5fd0c53b4101019
Parent:   fcc61af1097f9a5239bba36bc3db1d1c038f8b39
Author:   markdoliner at pidgin.im
Date:     08/15/10 04:42:30
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/74e057012b58f5f94a09d304a5fd0c53b4101019

Changelog: 

Change the "length of bstream" data type to be a gsize, since it represents
the size of a buffer.  There's no reason this should ever be negative.
It probably shouldn't be more than 32 bits, either, but gsize still seems
more appropriate to me

Changes against parent fcc61af1097f9a5239bba36bc3db1d1c038f8b39

  patched  libpurple/protocols/oscar/bstream.c
  patched  libpurple/protocols/oscar/odc.c
  patched  libpurple/protocols/oscar/oscar.h
  patched  libpurple/protocols/oscar/peer_proxy.c

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/bstream.c	05c8286d786fa8b4dd3d4ef41cd1ffbf4b0f85fb
+++ libpurple/protocols/oscar/bstream.c	97ff1f1c6dfd8071a78f76c04eccd44ac1973b43
@@ -24,7 +24,7 @@
 
 #include "oscar.h"
 
-int byte_stream_new(ByteStream *bs, guint32 len)
+int byte_stream_new(ByteStream *bs, size_t len)
 {
 	if (bs == NULL)
 		return -1;
@@ -32,7 +32,7 @@ int byte_stream_new(ByteStream *bs, guin
 	return byte_stream_init(bs, g_malloc(len), len);
 }
 
-int byte_stream_init(ByteStream *bs, guint8 *data, int len)
+int byte_stream_init(ByteStream *bs, guint8 *data, size_t len)
 {
 	if (bs == NULL)
 		return -1;
@@ -59,7 +59,7 @@ int byte_stream_curpos(ByteStream *bs)
 	return bs->offset;
 }
 
-int byte_stream_setpos(ByteStream *bs, unsigned int off)
+int byte_stream_setpos(ByteStream *bs, size_t off)
 {
 	g_return_val_if_fail(off <= bs->len, -1);
 
@@ -133,13 +133,13 @@ guint32 byte_stream_getle32(ByteStream *
 	return aimutil_getle32(bs->data + bs->offset - 4);
 }
 
-static void byte_stream_getrawbuf_nocheck(ByteStream *bs, guint8 *buf, int len)
+static void byte_stream_getrawbuf_nocheck(ByteStream *bs, guint8 *buf, size_t len)
 {
 	memcpy(buf, bs->data + bs->offset, len);
 	bs->offset += len;
 }
 
-int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, int len)
+int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, size_t len)
 {
 	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
 
@@ -147,7 +147,7 @@ int byte_stream_getrawbuf(ByteStream *bs
 	return len;
 }
 
-guint8 *byte_stream_getraw(ByteStream *bs, int len)
+guint8 *byte_stream_getraw(ByteStream *bs, size_t len)
 {
 	guint8 *ob;
 
@@ -158,7 +158,7 @@ guint8 *byte_stream_getraw(ByteStream *b
 	return ob;
 }
 
-char *byte_stream_getstr(ByteStream *bs, int len)
+char *byte_stream_getstr(ByteStream *bs, size_t len)
 {
 	char *ob;
 
@@ -219,7 +219,7 @@ int byte_stream_putle32(ByteStream *bs, 
 }
 
 
-int byte_stream_putraw(ByteStream *bs, const guint8 *v, int len)
+int byte_stream_putraw(ByteStream *bs, const guint8 *v, size_t len)
 {
 	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
 
@@ -233,7 +233,7 @@ int byte_stream_putstr(ByteStream *bs, c
 	return byte_stream_putraw(bs, (guint8 *)str, strlen(str));
 }
 
-int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, int len)
+int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, size_t len)
 {
 	g_return_val_if_fail(byte_stream_bytes_left(srcbs) >= len, 0);
 	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
============================================================
--- libpurple/protocols/oscar/oscar.h	07322c448a62514fdc745cdf159f60b9ea932d9a
+++ libpurple/protocols/oscar/oscar.h	1d89ef59b02cf5d9827df8b375fee765ac121887
@@ -238,8 +238,8 @@ struct _ByteStream
 struct _ByteStream
 {
 	guint8 *data;
-	guint32 len;
-	guint32 offset;
+	size_t len;
+	size_t offset;
 };
 
 struct _QueuedSnac
@@ -1209,12 +1209,12 @@ void aim_genericreq_l(OscarData *od, Fla
 void aim_genericreq_l(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *);
 
 /* bstream.c */
-int byte_stream_new(ByteStream *bs, guint32 len);
-int byte_stream_init(ByteStream *bs, guint8 *data, int len);
+int byte_stream_new(ByteStream *bs, size_t len);
+int byte_stream_init(ByteStream *bs, guint8 *data, size_t len);
 void byte_stream_destroy(ByteStream *bs);
 int byte_stream_bytes_left(ByteStream *bs);
 int byte_stream_curpos(ByteStream *bs);
-int byte_stream_setpos(ByteStream *bs, unsigned int off);
+int byte_stream_setpos(ByteStream *bs, size_t off);
 void byte_stream_rewind(ByteStream *bs);
 int byte_stream_advance(ByteStream *bs, int n);
 guint8 byte_stream_get8(ByteStream *bs);
@@ -1223,18 +1223,18 @@ guint32 byte_stream_getle32(ByteStream *
 guint8 byte_stream_getle8(ByteStream *bs);
 guint16 byte_stream_getle16(ByteStream *bs);
 guint32 byte_stream_getle32(ByteStream *bs);
-int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, int len);
-guint8 *byte_stream_getraw(ByteStream *bs, int len);
-char *byte_stream_getstr(ByteStream *bs, int len);
+int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, size_t len);
+guint8 *byte_stream_getraw(ByteStream *bs, size_t len);
+char *byte_stream_getstr(ByteStream *bs, size_t len);
 int byte_stream_put8(ByteStream *bs, guint8 v);
 int byte_stream_put16(ByteStream *bs, guint16 v);
 int byte_stream_put32(ByteStream *bs, guint32 v);
 int byte_stream_putle8(ByteStream *bs, guint8 v);
 int byte_stream_putle16(ByteStream *bs, guint16 v);
 int byte_stream_putle32(ByteStream *bs, guint32 v);
-int byte_stream_putraw(ByteStream *bs, const guint8 *v, int len);
+int byte_stream_putraw(ByteStream *bs, const guint8 *v, size_t len);
 int byte_stream_putstr(ByteStream *bs, const char *str);
-int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, int len);
+int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, size_t len);
 int byte_stream_putuid(ByteStream *bs, OscarData *od);
 int byte_stream_putcaps(ByteStream *bs, guint64 caps);
 
============================================================
--- libpurple/protocols/oscar/odc.c	e6cd92dd491289b22ceb9346159a79891c8d8f60
+++ libpurple/protocols/oscar/odc.c	7c8938bf4dd060a7eca1e2ddf60e6d1167cd3d9f
@@ -90,7 +90,7 @@ peer_odc_send(PeerConnection *conn, OdcF
 	ByteStream bs;
 
 	purple_debug_info("oscar", "Outgoing ODC frame to %s with "
-		"type=0x%04x, flags=0x%04x, payload length=%u\n",
+		"type=0x%04x, flags=0x%04x, payload length=%" G_GSIZE_FORMAT "\n",
 		conn->bn, frame->type, frame->flags, frame->payload.len);
 
 	account = purple_connection_get_account(conn->od->gc);
@@ -505,7 +505,7 @@ peer_odc_recv_frame(PeerConnection *conn
 	byte_stream_getrawbuf(bs, frame->bn, 32);
 
 	purple_debug_info("oscar", "Incoming ODC frame from %s with "
-			"type=0x%04x, flags=0x%04x, payload length=%u\n",
+			"type=0x%04x, flags=0x%04x, payload length=%" G_GSIZE_FORMAT "\n",
 			frame->bn, frame->type, frame->flags, frame->payload.len);
 
 	if (!conn->ready)
============================================================
--- libpurple/protocols/oscar/peer_proxy.c	2849544369245997d353958e101de7782b673f5f
+++ libpurple/protocols/oscar/peer_proxy.c	08d1d3abd3cc0049c3664ead88b064b9b064a5ba
@@ -32,8 +32,8 @@ peer_proxy_send(PeerConnection *conn, Pr
 	ByteStream bs;
 
 	purple_debug_info("oscar", "Outgoing peer proxy frame with "
-			"type=0x%04hx, unknown=0x%08x, "
-			"flags=0x%04hx, and payload length=%hd\n",
+			"type=0x%04hx, unknown=0x%08x, flags=0x%04hx, and "
+			"payload length=%" G_GSIZE_FORMAT "\n",
 			frame->type, frame->unknown,
 			frame->flags, frame->payload.len);
 
@@ -129,8 +129,8 @@ peer_proxy_recv_frame(PeerConnection *co
 peer_proxy_recv_frame(PeerConnection *conn, ProxyFrame *frame)
 {
 	purple_debug_info("oscar", "Incoming peer proxy frame with "
-			"type=0x%04hx, unknown=0x%08x, "
-			"flags=0x%04hx, and payload length=%hd\n", frame->type,
+			"type=0x%04hx, unknown=0x%08x, flags=0x%04hx, and "
+			"payload length=%" G_GSIZE_FORMAT "\n", frame->type,
 			frame->unknown, frame->flags, frame->payload.len);
 
 	if (frame->type == PEER_PROXY_TYPE_CREATED)


More information about the Commits mailing list