[hipl-dev] Re: [Branch ~hipl-core/hipl/mobility-fixes] Rev 5176: moved hip_get_locator_addr_item_count to update module

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-dev@xxxxxxxxxxxxx
  • Date: Fri, 19 Nov 2010 21:04:36 +0100

On Fri, Nov 19, 2010 at 05:39:30PM +0000, noreply@xxxxxxxxxxxxx wrote:
> ------------------------------------------------------------
> revno: 5176
> committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
> branch nick: mobility-fixes
> timestamp: Fri 2010-11-19 18:37:09 +0100
> message:
>   moved hip_get_locator_addr_item_count to update module
>   
> --- modules/update/hipd/update.c      2010-11-19 17:28:54 +0000
> +++ modules/update/hipd/update.c      2010-11-19 17:37:09 +0000
> @@ -654,6 +654,61 @@
>  
> +static struct in6_addr *hip_get_locator_item_address(void *item)
> +{
> +    struct hip_locator_info_addr_item *temp;
> +
> +    temp = (struct hip_locator_info_addr_item *) item;

pointless void* cast

> +int hip_get_locator_addr_item_count(const struct hip_locator *locator)
> +{
> +    const char *address_pointer = (const char *) (locator + 1);
> +    int amount                  = 0;
> +    uint8_t type;
> +
> +    while (address_pointer <
> +          ((const char *) locator) + hip_get_param_contents_len(locator)) {
> +        type = ((const struct hip_locator_info_addr_item *)
> +               address_pointer)->locator_type;

I'm sure this can be done with less casts.  Untested:

int hip_get_locator_addr_item_count(const struct hip_locator *locator)
{
    const struct hip_locator *address_pointer = locator + 1;
    int amount = 0;
    uint8_t type;

    while (address_pointer < locator + hip_get_param_contents_len(locator)) {
        type = ((const struct hip_locator_info_addr_item *) 
address_pointer)->locator_type;

I'm surprised this cast is correct.

Diego

Other related posts: