crfsdctl: fix unaligned access fault in pr_hello
Alex Chiang
achiang at hp.com
Fri May 2 13:52:04 PDT 2008
Hi Zach,
Not sure how much we care about this, but I get at least one
unaligned access warning while running crfsdctl snoop:
header id 1 info 0 bytes 4 type 0 [CRFS_MSG_HELLO]
crfsdctl(7148): unaligned access to 0x6000000000006f15, ip=0x4000000000003aa1
hello ver 1
Here's a patch that fixes it -- there are definitely more clever
ways to do this, but memcpy is really simple to understand, and
snooping definitely isn't in the performance path. ;)
/ac
Fix unaligned access fault in pr_hello().
Signed-off-by: Alex Chiang <achiang at hp.com>
diff -r 77848719c4ba crfsdctl/decode.c
--- a/crfsdctl/decode.c Tue Apr 22 14:03:17 2008 -0700
+++ b/crfsdctl/decode.c Fri May 02 14:39:25 2008 -0600
@@ -203,12 +203,13 @@ static void pr_hello(char *indent, void
static void pr_hello(char *indent, void *buf, size_t bytes,
struct func_ret *fr)
{
- struct crfs_msg_hello *hel = buf;
-
- printf("%shello ver %u\n", indent, from_be32(hel->ver));
-
- fr->next_func = NULL;
- fr->consumed = sizeof(*hel);
+ struct crfs_msg_hello hel;
+
+ memcpy(&hel, buf, sizeof(hel));
+ printf("%shello ver %u\n", indent, from_be32(hel.ver));
+
+ fr->next_func = NULL;
+ fr->consumed = sizeof(hel);
}
static void pr_header(char *indent, void *buf, size_t bytes,
More information about the crfs-devel
mailing list