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

container_of: use offsetof from stddef

Use standardized offsetof() macro from stddef.
Helps to build valid code with latest gcc10 with -O2.
This commit is contained in:
Zdenek Kabelac 2020-03-05 12:58:34 +01:00
parent b3fa71fbd8
commit f439716b75
2 changed files with 5 additions and 10 deletions

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018 Red Hat, Inc. All rights reserved.
// Copyright (C) 2018 - 2020 Red Hat, Inc. All rights reserved.
//
// This file is part of LVM2.
//
@ -13,10 +13,12 @@
#ifndef BASE_MEMORY_CONTAINER_OF_H
#define BASE_MEMORY_CONTAINER_OF_H
#include <stddef.h> // offsetof
//----------------------------------------------------------------
#define container_of(v, t, head) \
((t *)((const char *)(v) - (const char *)&((t *) 0)->head))
((t *)((const char *)(v) - offsetof(t, head)))
//----------------------------------------------------------------

View File

@ -16,19 +16,12 @@
#define BCACHE_H
#include "device_mapper/all.h"
#include "base/memory/container_of.h"
#include <linux/fs.h>
#include <stdint.h>
#include <stdbool.h>
/*----------------------------------------------------------------*/
// FIXME: move somewhere more sensible
#define container_of(v, t, head) \
((t *)((const char *)(v) - (const char *)&((t *) 0)->head))
/*----------------------------------------------------------------*/
enum dir {
DIR_READ,
DIR_WRITE