From 1c811f9fddf336317099e7ec73e28131acf65be8 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Sat, 22 Dec 2012 07:54:54 -0500 Subject: [PATCH] Rework set_header_word macros Rework the set_header_word macros so that all compilers are happy: - the use of offsetof() is avoided, as it has an issue on IRIX when the result is not constant - the assignment within the macro is explicitely sequenced before the function call to avoid a gcc sequence-point warning Reviewed-on: http://gerrit.openafs.org/8816 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear (cherry picked from commit 7f96084969d3082842a9575ee8ff7da8c52a0796) Change-Id: Iefdf7f6dbb60ffc569b67b3c89893fb43527eb02 Reviewed-on: http://gerrit.openafs.org/8818 Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Stephan Wiesand --- src/budb/database.h | 8 +++++--- src/kauth/kadatabase.c | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/budb/database.h b/src/budb/database.h index fdb3da5982..3b8f67177c 100644 --- a/src/budb/database.h +++ b/src/budb/database.h @@ -293,9 +293,11 @@ struct memoryDB { /* in core copies of database structures */ extern struct memoryDB db; #define set_header_word(ut,field,value) \ - dbwrite ((ut), (offsetof(struct dbHeader, field)), \ - ((db.h.field = (value)), (char *)&(db.h.field)), \ - sizeof(afs_int32)) + ( \ + (db.h.field) = (value), \ + dbwrite((ut), ((char *)&(db.h.field) - (char *)&db.h), \ + ((char *)&(db.h.field)), sizeof(afs_int32)) \ + ) #define set_word_offset(ut,a,b,offset,value) \ dbwrite ((ut), (a)+(offset), \ diff --git a/src/kauth/kadatabase.c b/src/kauth/kadatabase.c index 0a9fe9ca99..3524688563 100644 --- a/src/kauth/kadatabase.c +++ b/src/kauth/kadatabase.c @@ -32,7 +32,12 @@ extern Date cheaderReadTime; /* time cheader last read in */ -#define set_header_word(tt,field,value) kawrite ((tt), (offsetof(struct kaheader, field)), ((cheader.field = (value)), (char *)&(cheader.field)), sizeof(afs_int32)) +#define set_header_word(tt,field,value) \ + ( \ + (cheader.field) = (value), \ + kawrite((tt), ((char *)&(cheader.field) - (char *)&cheader), \ + (char *)&(cheader.field), sizeof(afs_int32)) \ + ) #define inc_header_word(tt,field) kawrite ((tt), (offsetof(struct kaheader, field)), ((cheader.field = (htonl(ntohl(cheader.field)+1))), (char *)&(cheader.field)), sizeof(afs_int32))