diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-02-08 00:46:01 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-02-08 00:46:01 +0100 |
commit | 89a73382b14904cd762529a79ca74e8c2b389dbc (patch) | |
tree | 20e19fa52330cd7e6e9c2aa4aa8c661225ac287c | |
parent | 60c1f2706e30eacc29296e6cb5d9327c85a01340 (diff) | |
download | sparse-89a73382b14904cd762529a79ca74e8c2b389dbc.tar.gz |
ptrlist: make ptr_list_nth_entry() generic with ptr_list_nth()
The library operation on pointer list necessarily act on the untyped
version of the list. To use them with type checking, they must either
be wrapped in inline function using the desired type or be used via
some macro doing the type checking.
Do this later solution for ptr_list_nth_entry().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | ptrlist.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -73,6 +73,10 @@ extern void __free_ptr_list(struct ptr_list **); __free_ptr_list((struct ptr_list **)(list)); \ } while (0) +#define ptr_list_nth(lst, nth) ({ \ + struct ptr_list* head = (struct ptr_list*)(lst); \ + (__typeof__((lst)->list[0])) ptr_list_nth_entry(head, nth);\ + }) //////////////////////////////////////////////////////////////////////// // API |