Re: [Redbutton-devel] SF.net SVN: redbutton:[533] redbutton-download/trunk
Brought to you by:
skilvington
|
From: Stuart H. <st...@li...> - 2010-01-27 13:22:55
|
Hi,
Tested here on ARM and working great :-) Thanks for getting it fixed.
Stuart
ski...@us... wrote:
> Revision: 533
> http://redbutton.svn.sourceforge.net/redbutton/?rev=533&view=rev
> Author: skilvington
> Date: 2010-01-27 13:03:34 +0000 (Wed, 27 Jan 2010)
>
> Log Message:
> -----------
> avoid reading shorts/ints from addresses which are not 4-byte aligned - needed for ARM
>
> Modified Paths:
> --------------
> redbutton-download/trunk/biop.c
> redbutton-download/trunk/biop.h
>
> Modified: redbutton-download/trunk/biop.c
> ===================================================================
> --- redbutton-download/trunk/biop.c 2009-12-21 11:12:59 UTC (rev 532)
> +++ redbutton-download/trunk/biop.c 2010-01-27 13:03:34 UTC (rev 533)
> @@ -3,7 +3,7 @@
> */
>
> /*
> - * Copyright (C) 2005, Simon Kilvington
> + * Copyright (C) 2005-2010, Simon Kilvington
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> @@ -69,7 +69,7 @@
> error("Invalid BIOP header");
> return false;
> }
> - size = biop_uint32(data->byte_order, data->message_size);
> + size = biop_uint32(data->byte_order, (unsigned char *) &data->message_size);
> vverbose("BIOP message_size=%u", size);
> if(bytes_left < sizeof(struct BIOPMessageHeader) + size)
> {
> @@ -167,7 +167,7 @@
> struct biop_sequence info;
> uint16_t pid;
>
> - nbindings = biop_uint16(byte_order, *((uint16_t *) data));
> + nbindings = biop_uint16(byte_order, data);
> data += 2;
> vverbose("binding_count: %u", nbindings);
>
> @@ -257,13 +257,13 @@
> data += biop_sequence(byte_order, data, &type);
> vverbose(" typeId: '%.*s'", type.size, type.data);
>
> - nprofiles = biop_uint32(byte_order, *((uint32_t *) data));
> + nprofiles = biop_uint32(byte_order, data);
> data += 4;
> vverbose(" taggedProfiles_count: %u", nprofiles);
> for(i=0; i<nprofiles; i++)
> {
> vverbose(" IOP::taggedProfile %u", i);
> - tag = biop_uint32(byte_order, *((uint32_t *) data));
> + tag = biop_uint32(byte_order, data);
> data += 4;
> data += biop_sequence(byte_order, data, &profile);
> if(tag == TAG_BIOP)
> @@ -275,17 +275,17 @@
> /* ncomponents = *(profile.data); */
> profile.data += 1;
> /* BIOP::ObjectLocation */
> - if(biop_uint32(profile_bo, *((uint32_t *) profile.data)) != TAG_ObjectLocation)
> + if(biop_uint32(profile_bo, profile.data) != TAG_ObjectLocation)
> fatal("Expecting BIOP::ObjectLocation");
> profile.data += 4;
> /* component_data_length = *(profile.data); */
> profile.data += 1;
> /* carouselId */
> - ior->carousel_id = biop_uint32(profile_bo, *((uint32_t *) profile.data));
> + ior->carousel_id = biop_uint32(profile_bo, profile.data);
> profile.data += 4;
> vverbose(" carouselId: %u", ior->carousel_id);
> /* moduleId */
> - ior->module_id = biop_uint16(profile_bo, *((uint16_t *) profile.data));
> + ior->module_id = biop_uint16(profile_bo, profile.data);
> profile.data += 2;
> vverbose(" moduleId: %u", ior->module_id);
> /* BIOP version */
> @@ -298,7 +298,7 @@
> vverbose(" objectKey: '%.*s'", ior->key.size, ior->key.data);
> vhexdump(ior->key.data, ior->key.size);
> /* DSM::ConnBinder */
> - if(biop_uint32(profile_bo, *((uint32_t *) profile.data)) != TAG_ConnBinder)
> + if(biop_uint32(profile_bo, profile.data) != TAG_ConnBinder)
> fatal("Expecting DSM::ConnBinder");
> profile.data += 4;
> vverbose(" DSM::ConnBinder");
> @@ -310,22 +310,22 @@
> if(taps_count > 0)
> {
> vverbose(" BIOP::Tap");
> - /* id = biop_uint16(profile_bo, *((uint16_t *) profile.data)) */
> + /* id = biop_uint16(profile_bo, profile.data) */
> profile.data += 2;
> - if(biop_uint16(profile_bo, *((uint16_t *) profile.data)) != BIOP_DELIVERY_PARA_USE)
> + if(biop_uint16(profile_bo, profile.data) != BIOP_DELIVERY_PARA_USE)
> fatal("Expecting BIOP_DELIVERY_PARA_USE");
> profile.data += 2;
> vverbose(" use: BIOP_DELIVERY_PARA_USE");
> - ior->association_tag = biop_uint16(profile_bo, *((uint16_t *) profile.data));
> + ior->association_tag = biop_uint16(profile_bo, profile.data);
> profile.data += 2;
> vverbose(" association_tag: %u", ior->association_tag);
> if(*profile.data != SELECTOR_TYPE_MESSAGE_LEN)
> fatal("Expecting selector_length %u", SELECTOR_TYPE_MESSAGE_LEN);
> profile.data += 1;
> - if(biop_uint16(profile_bo, *((uint16_t *) profile.data)) != SELECTOR_TYPE_MESSAGE)
> + if(biop_uint16(profile_bo, profile.data) != SELECTOR_TYPE_MESSAGE)
> fatal("Expecting selector_type MESSAGE");
> profile.data += 2;
> - transaction_id = biop_uint32(profile_bo, *((uint32_t *) profile.data));
> + transaction_id = biop_uint32(profile_bo, profile.data);
> profile.data += 4;
> vverbose(" transaction_id: %u", transaction_id);
> }
> @@ -348,15 +348,14 @@
> */
>
> uint16_t
> -biop_uint16(uint8_t byte_order, uint16_t raw)
> +biop_uint16(uint8_t byte_order, unsigned char *raw)
> {
> - uint8_t *p = (uint8_t *) &raw;
> uint16_t val;
>
> if(byte_order == BIOP_BIGENDIAN)
> - val = (p[0] << 8) + p[1];
> + val = (raw[0] << 8) + raw[1];
> else
> - val = (p[1] << 8) + p[0];
> + val = (raw[1] << 8) + raw[0];
>
> return val;
> }
> @@ -366,15 +365,14 @@
> */
>
> uint32_t
> -biop_uint32(uint8_t byte_order, uint32_t raw)
> +biop_uint32(uint8_t byte_order, unsigned char *raw)
> {
> - uint8_t *p = (uint8_t *) &raw;
> uint32_t val;
>
> if(byte_order == BIOP_BIGENDIAN)
> - val = (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
> + val = (raw[0] << 24) + (raw[1] << 16) + (raw[2] << 8) + raw[3];
> else
> - val = (p[3] << 24) + (p[2] << 16) + (p[1] << 8) + p[0];
> + val = (raw[3] << 24) + (raw[2] << 16) + (raw[1] << 8) + raw[0];
>
> return val;
> }
> @@ -399,7 +397,7 @@
> uint32_t
> biop_sequence65535(uint8_t byte_order, unsigned char *raw, struct biop_sequence *out)
> {
> - out->size = biop_uint16(byte_order, *((uint16_t *) raw));
> + out->size = biop_uint16(byte_order, raw);
> out->data = &raw[2];
>
> return 2 + out->size;
> @@ -412,7 +410,7 @@
> uint32_t
> biop_sequence(uint8_t byte_order, unsigned char *raw, struct biop_sequence *out)
> {
> - out->size = biop_uint32(byte_order, *((uint32_t *) raw));
> + out->size = biop_uint32(byte_order, raw);
> out->data = &raw[4];
>
> return 4 + out->size;
>
> Modified: redbutton-download/trunk/biop.h
> ===================================================================
> --- redbutton-download/trunk/biop.h 2009-12-21 11:12:59 UTC (rev 532)
> +++ redbutton-download/trunk/biop.h 2010-01-27 13:03:34 UTC (rev 533)
> @@ -5,7 +5,7 @@
> */
>
> /*
> - * Copyright (C) 2005, Simon Kilvington
> + * Copyright (C) 2005-2010, Simon Kilvington
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> @@ -105,8 +105,8 @@
> uint32_t process_iop_ior(uint8_t, unsigned char *, struct biop_iop_ior *);
> uint16_t process_biop_service_gateway_info(uint16_t, struct assoc *, unsigned char *, uint16_t);
>
> -uint16_t biop_uint16(uint8_t, uint16_t);
> -uint32_t biop_uint32(uint8_t, uint32_t);
> +uint16_t biop_uint16(uint8_t, unsigned char *);
> +uint32_t biop_uint32(uint8_t, unsigned char *);
>
> uint32_t biop_sequence255(unsigned char *, struct biop_sequence *);
> uint32_t biop_sequence65535(uint8_t, unsigned char *, struct biop_sequence *);
>
>
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Redbutton-devel mailing list
> Red...@li...
> https://lists.sourceforge.net/lists/listinfo/redbutton-devel
>
|