Blob Blame History Raw
From ed47b3a326d40e864926c0a456903bdbd3c23e87 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Fri, 1 Nov 2019 01:57:16 +0100
Subject: [PATCH] macros.h: introduce sizeof_field macro

Handy for field size checks.

* macros.h (sizeof_field): New macro.
(offsetofend): Use it.
---
 macros.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/macros.h b/macros.h
index c58ac6a..d7e191f 100644
--- a/macros.h
+++ b/macros.h
@@ -37,9 +37,11 @@
 #  define ROUNDUP(val_, div_) (ROUNDUP_DIV((val_), (div_)) * (div_))
 # endif
 
+# define sizeof_field(type_, member_) (sizeof(((type_ *)0)->member_))
+
 # ifndef offsetofend
 #  define offsetofend(type_, member_)	\
-	(offsetof(type_, member_) + sizeof(((type_ *)0)->member_))
+	(offsetof(type_, member_) + sizeof_field(type_, member_))
 # endif
 
 # ifndef cast_ptr
-- 
2.1.4