Module Name:    src
Committed By:   christos
Date:           Sun Jul 17 20:47:39 UTC 2011

Modified Files:
        src/lib/libc/db/btree: bt_debug.c

Log Message:
fix type punned warnings in debugging code.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/db/btree/bt_debug.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/db/btree/bt_debug.c
diff -u src/lib/libc/db/btree/bt_debug.c:1.15 src/lib/libc/db/btree/bt_debug.c:1.16
--- src/lib/libc/db/btree/bt_debug.c:1.15	Wed Sep 10 13:52:35 2008
+++ src/lib/libc/db/btree/bt_debug.c	Sun Jul 17 16:47:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bt_debug.c,v 1.15 2008/09/10 17:52:35 joerg Exp $	*/
+/*	$NetBSD: bt_debug.c,v 1.16 2011/07/17 20:47:39 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: bt_debug.c,v 1.15 2008/09/10 17:52:35 joerg Exp $");
+__RCSID("$NetBSD: bt_debug.c,v 1.16 2011/07/17 20:47:39 christos Exp $");
 
 #include <assert.h>
 #include <stdio.h>
@@ -124,6 +124,22 @@
 	}
 }
 
+static pgno_t
+__bt_pgno_t(const void *m)
+{
+	pgno_t r;
+	memcpy(&r, m, sizeof(r));
+	return r;
+}
+
+static uint32_t
+__bt_uint32_t(const void *m)
+{
+	uint32_t r;
+	memcpy(&r, m, sizeof(r));
+	return r;
+}
+
 /*
  * BT_DNPAGE -- Dump the page
  *
@@ -206,15 +222,16 @@
 			if (bl->flags & P_BIGKEY)
 				(void)fprintf(stderr,
 				    "big key page %lu size %u/",
-				    (unsigned long) *(pgno_t *)(void *)bl->bytes,
-				    *(uint32_t *)(void *)(bl->bytes + sizeof(pgno_t)));
+				    (unsigned long) __bt_pgno_t(bl->bytes),
+				    __bt_uint32_t(bl->bytes + sizeof(pgno_t)));
 			else if (bl->ksize)
 				(void)fprintf(stderr, "%s/", bl->bytes);
 			if (bl->flags & P_BIGDATA)
 				(void)fprintf(stderr,
 				    "big data page %lu size %u",
-				    (unsigned long) *(pgno_t *)(void *)(bl->bytes + bl->ksize),
-				    *(uint32_t *)(void *)(bl->bytes + bl->ksize +
+				    (unsigned long)
+				    __bt_pgno_t(bl->bytes + bl->ksize),
+				    __bt_uint32_t(bl->bytes + bl->ksize +
 				    sizeof(pgno_t)));
 			else if (bl->dsize)
 				(void)fprintf(stderr, "%.*s",
@@ -225,8 +242,8 @@
 			if (rl->flags & P_BIGDATA)
 				(void)fprintf(stderr,
 				    "big data page %lu size %u",
-				    (unsigned long) *(pgno_t *)(void *)rl->bytes,
-				    *(uint32_t *)(void *)(rl->bytes + sizeof(pgno_t)));
+				    (unsigned long) __bt_pgno_t(rl->bytes),
+				    __bt_uint32_t(rl->bytes + sizeof(pgno_t)));
 			else if (rl->dsize)
 				(void)fprintf(stderr,
 				    "%.*s", (int)rl->dsize, rl->bytes);

Reply via email to