Re: [Rhythmbox-devel] music sharing patch #2
- From: Christophe Fergeau <teuf gnome org>
- To: rhythmbox-devel gnome org
- Subject: Re: [Rhythmbox-devel] music sharing patch #2
- Date: Wed, 10 Aug 2005 22:54:14 +0200
> static gint
> rb_daap_buffer_read_int32 (const char *buf, gsize remaining)
> {
> int i;
> gint ret;
>
> if (remaining < 4)
> return 0;
>
> return GINT32_FROM_BE (buf[0] << 24 + buf[1] << 16 + buf[2] << 8 + buf[3]);
> }
Iirc, I had (really) bad experiences in the past mixing (signed) chars,
bit shifts and additions that way. I'd do something like that instead:
static gint
rb_daap_buffer_read_int32 (const guchar *buf, gsize remaining)
{
if (remaining < 4)
return 0;
return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
}
The code you proposed might be right, but by reading it, I'm not
immediatly convinced that it will do the right things with something
like 0x00, 0x00, 0xf0, 0x00 in the input buffer (I suspect you'll get
0xfffff000 instead of 0xf000)
Christophe
> If the DAAP protocol requires wire data to be aligned we could
> potentially verify the alignment and read the data directly (which is
> what D-BUS does), but this way seems safer.
>
> _______________________________________________
> rhythmbox-devel mailing list
> rhythmbox-devel gnome org
> http://mail.gnome.org/mailman/listinfo/rhythmbox-devel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]