Looks Good to me.

Ethan

On Mon, Mar 21, 2011 at 2:10 PM, Ben Pfaff <[email protected]> wrote:
> It totally makes sense to pass a const struct list * to one of these
> functions.  Ideally the return type would be the same as the argument
> type but C can't handle that, so this is the best second choice.
> ---
>  lib/list.c |   16 ++++++++++------
>  lib/list.h |    6 +++---
>  2 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/lib/list.c b/lib/list.c
> index 6d5f6fe..0f4f2f8 100644
> --- a/lib/list.c
> +++ b/lib/list.c
> @@ -127,20 +127,24 @@ list_pop_back(struct list *list)
>     return back;
>  }
>
> -/* Returns the front element in 'list'.
> -   Undefined behavior if 'list' is empty. */
> +/* Returns the front element in 'list_'.
> +   Undefined behavior if 'list_' is empty. */
>  struct list *
> -list_front(struct list *list)
> +list_front(const struct list *list_)
>  {
> +    struct list *list = (struct list *) list_;
> +
>     assert(!list_is_empty(list));
>     return list->next;
>  }
>
> -/* Returns the back element in 'list'.
> -   Undefined behavior if 'list' is empty. */
> +/* Returns the back element in 'list_'.
> +   Undefined behavior if 'list_' is empty. */
>  struct list *
> -list_back(struct list *list)
> +list_back(const struct list *list_)
>  {
> +    struct list *list = (struct list *) list_;
> +
>     assert(!list_is_empty(list));
>     return list->prev;
>  }
> diff --git a/lib/list.h b/lib/list.h
> index ddb0e65..915ee85 100644
> --- a/lib/list.h
> +++ b/lib/list.h
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2008, 2009, 2010 Nicira Networks.
> + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
> @@ -47,8 +47,8 @@ struct list *list_pop_front(struct list *);
>  struct list *list_pop_back(struct list *);
>
>  /* List elements. */
> -struct list *list_front(struct list *);
> -struct list *list_back(struct list *);
> +struct list *list_front(const struct list *);
> +struct list *list_back(const struct list *);
>
>  /* List properties. */
>  size_t list_size(const struct list *);
> --
> 1.7.1
>
>
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to