shithub: lwext4

Download patch

ref: d811f584142a7cc4cc592633f56e4a9514b098b0
parent: e0099ab67ad94cce497c1a04da78511344dafc31
author: gkostka <[email protected]>
date: Tue Oct 27 16:40:36 EDT 2015

Refactor ext4_offsetof to offsetof and move to ext4_types.h

--- a/lwext4/ext4_config.h
+++ b/lwext4/ext4_config.h
@@ -133,16 +133,7 @@
 #define CONFIG_EXTENT_FULL 1
 #endif
 
-#ifdef __GNUC__
-#ifndef __unused
-#define __unused __attribute__ ((__unused__))
-#endif
-#endif
 
-#ifndef ext4_offsetof
-#define ext4_offsetof(type, field) \
-	((long)(&(((type *)0)->field)))
-#endif
 
 #endif /* EXT4_CONFIG_H_ */
 
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -855,7 +855,7 @@
 	if (inode_size > EXT4_GOOD_OLD_INODE_SIZE)
 		ext4_inode_set_extra_isize(inode,
 				sizeof(struct ext4_inode) -
-				ext4_offsetof(struct ext4_inode,
+				offsetof(struct ext4_inode,
 					extra_isize));
 
 	/* Reset blocks array. For symbolic link inode, just
--- a/lwext4/ext4_super.c
+++ b/lwext4/ext4_super.c
@@ -83,7 +83,7 @@
 static uint32_t ext4_sb_csum(struct ext4_sblock *s)
 {
 	return ext4_crc32c(~0, s,
-			ext4_offsetof(struct ext4_sblock, checksum));
+			offsetof(struct ext4_sblock, checksum));
 }
 
 static bool ext4_sb_verify_csum(struct ext4_sblock *s)
--- a/lwext4/ext4_types.h
+++ b/lwext4/ext4_types.h
@@ -46,6 +46,7 @@
 #include "ext4_blockdev.h"
 #include "tree.h"
 
+#include <stddef.h>
 #include <stdint.h>
 
 #define EXT4_CHECKSUM_CRC32C 1
@@ -932,6 +933,18 @@
 #define ext4_set8                                                              \
 	(s, f, v) do { (s)->f = (v); }                                         \
 	while (0)
+
+
+#ifdef __GNUC__
+#ifndef __unused
+#define __unused __attribute__ ((__unused__))
+#endif
+#endif
+
+#ifndef offsetof
+#define offsetof(type, field) 		\
+	((size_t)(&(((type *)0)->field)))
+#endif
 
 #endif /* EXT4_TYPES_H_ */