1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

list: use container_of

Reuse macro
This commit is contained in:
Zdenek Kabelac 2020-05-15 14:41:23 +02:00
parent 16da6651a1
commit deb5160181
2 changed files with 4 additions and 6 deletions

View File

@ -1,7 +1,7 @@
#ifndef BASE_DATA_STRUCT_LIST_H
#define BASE_DATA_STRUCT_LIST_H
#include <stddef.h> /* offsetof */
#include "base/memory/container_of.h"
//----------------------------------------------------------------
@ -100,7 +100,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
* contained in a structure of type t, return the containing structure.
*/
#define dm_list_struct_base(v, t, head) \
((t *)((const char *)(v) - offsetof(t, head)))
container_of(v, t, head)
/*
* Given the address v of an instance of 'struct dm_list list' contained in

View File

@ -11,6 +11,8 @@
#ifndef _LVM_LVMLOCKD_INTERNAL_H
#define _LVM_LVMLOCKD_INTERNAL_H
#include "base/memory/container_of.h"
#define MAX_NAME 64
#define MAX_ARGS 64
@ -217,10 +219,6 @@ struct val_blk {
/* lm_unlock flags */
#define LMUF_FREE_VG 0x00000001
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;