From: Wouter Verhelst Date: Fri, 5 Jun 2009 19:43:54 +0000 (+0200) Subject: Avoid unaligned access X-Git-Url: http://git.alex.org.uk Avoid unaligned access nbd-tester-client tried to write to a char array in a packed struct by casting it to an u64 pointer and dereferencing it. That causes unaligned access and, hence, a SIGBUS on SPARC. Fix by using memcpy instead. --- diff --git a/nbd-tester-client.c b/nbd-tester-client.c index 40a6363..3dde737 100644 --- a/nbd-tester-client.c +++ b/nbd-tester-client.c @@ -245,7 +245,7 @@ int throughput_test(gchar* hostname, int port, int sock, char sock_is_open, char } for(i=0;i+1024<=size;i+=1024) { if(do_write) { - *((u64*)req.handle)=i; + memcpy(&(req.handle),&i,sizeof(i)); req.from=htonll(i); write(sock, &req, sizeof(req)); printf("Requests(+): %d\n", ++requests);