summaryrefslogtreecommitdiffstats
path: root/sys/nfs/xdr_subs.h
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-08-19 14:50:12 +0000
committerpeter <peter@FreeBSD.org>1999-08-19 14:50:12 +0000
commitd4c0c0bd4aa267c169eeebee5cb975271791f325 (patch)
tree31c4b1f1dce04c753d163e872612edd34b581aa1 /sys/nfs/xdr_subs.h
parent7c5ab4e28ded2320501c6166e7cfe08a0942ec28 (diff)
downloadFreeBSD-src-d4c0c0bd4aa267c169eeebee5cb975271791f325.zip
FreeBSD-src-d4c0c0bd4aa267c169eeebee5cb975271791f325.tar.gz
Convert all the nfs macros to do { blah } while (0) to ensure it
works correctly in if/else etc. egcs had probably picked up most of the problems here before with "ambiguous braces" etc, but this should increase the robustness a bit. Based on an idea from Eivind Eklund.
Diffstat (limited to 'sys/nfs/xdr_subs.h')
-rw-r--r--sys/nfs/xdr_subs.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/nfs/xdr_subs.h b/sys/nfs/xdr_subs.h
index a77e5cf..bb60dd0 100644
--- a/sys/nfs/xdr_subs.h
+++ b/sys/nfs/xdr_subs.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95
- * $Id: xdr_subs.h,v 1.10 1998/05/31 20:09:01 peter Exp $
+ * $Id: xdr_subs.h,v 1.11 1999/06/05 05:35:03 peter Exp $
*/
@@ -55,36 +55,41 @@
#define fxdr_unsigned(t, v) ((t)ntohl((int32_t)(v)))
#define txdr_unsigned(v) (htonl((int32_t)(v)))
-#define fxdr_nfsv2time(f, t) { \
+#define fxdr_nfsv2time(f, t) \
+do { \
(t)->tv_sec = ntohl(((struct nfsv2_time *)(f))->nfsv2_sec); \
if (((struct nfsv2_time *)(f))->nfsv2_usec != 0xffffffff) \
(t)->tv_nsec = 1000 * ntohl(((struct nfsv2_time *)(f))->nfsv2_usec); \
else \
(t)->tv_nsec = 0; \
-}
-#define txdr_nfsv2time(f, t) { \
+} while (0)
+#define txdr_nfsv2time(f, t) \
+do { \
((struct nfsv2_time *)(t))->nfsv2_sec = htonl((f)->tv_sec); \
if ((f)->tv_nsec != -1) \
((struct nfsv2_time *)(t))->nfsv2_usec = htonl((f)->tv_nsec / 1000); \
else \
((struct nfsv2_time *)(t))->nfsv2_usec = 0xffffffff; \
-}
+} while (0)
-#define fxdr_nfsv3time(f, t) { \
+#define fxdr_nfsv3time(f, t) \
+do { \
(t)->tv_sec = ntohl(((struct nfsv3_time *)(f))->nfsv3_sec); \
(t)->tv_nsec = ntohl(((struct nfsv3_time *)(f))->nfsv3_nsec); \
-}
-#define txdr_nfsv3time(f, t) { \
+} while (0)
+#define txdr_nfsv3time(f, t) \
+do { \
((struct nfsv3_time *)(t))->nfsv3_sec = htonl((f)->tv_sec); \
((struct nfsv3_time *)(t))->nfsv3_nsec = htonl((f)->tv_nsec); \
-}
+} while (0)
#define fxdr_hyper(f) \
((((u_quad_t)ntohl(((u_int32_t *)(f))[0])) << 32) | \
(u_quad_t)(ntohl(((u_int32_t *)(f))[1])))
-#define txdr_hyper(f, t) { \
+#define txdr_hyper(f, t) \
+do { \
((u_int32_t *)(t))[0] = htonl((u_int32_t)((f) >> 32)); \
((u_int32_t *)(t))[1] = htonl((u_int32_t)((f) & 0xffffffff)); \
-}
+} while (0)
#endif
OpenPOWER on IntegriCloud