+2008-01-22 Guillem Jover <guillem@debian.org>
+
+ * lib/dpkg.h [!offsetof] (offsetof): New compatibilty macro.
+ * lib/parsedump.h (PKGIFPOFF): Use offsetof instead of ad-hoc
+ calculation.
+ (FILEFOFF): Likewise.
+ (struct fieldinfo): Change integer member type to size_t.
+ * lib/tarfn.c (TarChecksumOffset): Use offsetof instead of ad-hoc
+ calculation.
+
2008-01-22 Guillem Jover <guillem@debian.org>
* configure.ac (AC_CHECK_HEADERS): Check for 'stddef.h'.
struct fieldinfo;
-#define PKGIFPOFF(f) ((char*)(&(((struct pkginfoperfile *)0x1000)->f)) - \
- (char*)(struct pkginfoperfile *)0x1000)
+#define PKGIFPOFF(f) (offsetof(struct pkginfoperfile, f))
#define PKGPFIELD(pifp,of,type) (*(type*)((char*)(pifp)+(of)))
-#define FILEFOFF(f) ((char*)(&(((struct filedetails *)0x1000)->f)) - \
- (char*)(struct filedetails *)0x1000)
+#define FILEFOFF(f) (offsetof(struct filedetails, f))
#define FILEFFIELD(filedetail,of,type) (*(type*)((char*)(filedetail)+(of)))
typedef void freadfunction(struct pkginfo *pigp, struct pkginfoperfile *pifp,
const char *name;
freadfunction *rcall;
fwritefunction *wcall;
- unsigned int integer;
+ size_t integer;
};
void parseerr(FILE *file, const char *filename, int lno, FILE *warnto, int *warncount,
};
typedef struct TarHeader TarHeader;
-static const unsigned int TarChecksumOffset
- = (unsigned int)&(((TarHeader *)NULL)->Checksum);
+static const size_t TarChecksumOffset = offsetof(TarHeader, Checksum);
/* Octal-ASCII-to-long */
static long