From 5d8d7844bb3096a78d255f4dbc6cfe16b494fadd Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Mon, 6 Apr 2009 23:29:31 +0000 Subject: [PATCH] Avoid alignment problems by copying the crc from the header field into a local variable --- apps/shell/shell-rime-netcmd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/shell/shell-rime-netcmd.c b/apps/shell/shell-rime-netcmd.c index 55544b753..60c5065e8 100644 --- a/apps/shell/shell-rime-netcmd.c +++ b/apps/shell/shell-rime-netcmd.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: shell-rime-netcmd.c,v 1.7 2009/04/06 21:17:34 adamdunkels Exp $ + * $Id: shell-rime-netcmd.c,v 1.8 2009/04/06 23:29:31 adamdunkels Exp $ */ /** @@ -143,6 +143,7 @@ static void recv_trickle(struct trickle_conn *c) { struct trickle_msg *msg; + uint16_t crc; int len; msg = packetbuf_dataptr(); @@ -156,8 +157,9 @@ recv_trickle(struct trickle_conn *c) /* Make sure that the incoming command is null-terminated. */ msg->netcmd[len] = 0; - - if(msg->crc == crc16_data(msg->netcmd, len, 0)) { + memcpy(&crc, &msg->crc, sizeof(crc)); + + if(crc == crc16_data(msg->netcmd, len, 0)) { /* Start the server process with the incoming command. */ process_start(&shell_netcmd_server_process, msg->netcmd); }