Changeset a74d0ad in mainline


Ignore:
Timestamp:
2013-09-05T20:14:04Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
063a74b9
Parents:
aa2a049
Message:

Type check the member argument of list_get_instance macro.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/adt/list.h

    raa2a049 ra74d0ad  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
    3  * Copyright (c) 2011 Jiri Svoboda
     3 * Copyright (c) 2013 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    6565
    6666#define list_get_instance(link, type, member) \
    67         ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
     67        ((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member))))
    6868
    6969#define list_foreach(list, iterator) \
     
    281281}
    282282
     283/** Verify that argument type is a pointer to link_t (at compile time).
     284 *
     285 * This can be used to check argument type in a macro.
     286 */
     287static inline const void *list_link_to_void(const link_t *link)
     288{
     289        return link;
     290}
     291
    283292extern int list_member(const link_t *, const list_t *);
    284293extern void list_concat(list_t *, list_t *);
  • uspace/lib/c/include/adt/list.h

    raa2a049 ra74d0ad  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
    3  * Copyright (c) 2011 Jiri Svoboda
     3 * Copyright (c) 2013 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    6565
    6666#define list_get_instance(link, type, member) \
    67         ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
     67        ((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member))))
    6868
    6969#define list_foreach(list, iterator) \
     
    318318}
    319319
     320/** Verify that argument type is a pointer to link_t (at compile time).
     321 *
     322 * This can be used to check argument type in a macro.
     323 */
     324static inline const void *list_link_to_void(const link_t *link)
     325{
     326        return link;
     327}
     328
    320329extern int list_member(const link_t *, const list_t *);
    321330extern void list_concat(list_t *, list_t *);
Note: See TracChangeset for help on using the changeset viewer.