On Sat, Mar 3, 2012 at 09:55:51 -0600, Patrick Baggett wrote: > Where can I read the source for "nbd-tester-client.c"? I just did a quick > scan of "ghash.c" but I didn't see anything really silly going on, so I'd > like to check this file. All copies I can find of "nbd-tester-client.c" > seem to be short (<600 lines) and not use glib at all. > It does this:
/* * This is the reply packet that nbd-server sends back to the client after * it has completed an I/O request (or an error occurs). */ struct nbd_reply { __be32 magic; __be32 error; /* 0 = ok, else error */ char handle[8]; /* handle you got from request */ }; [...] GHashTable *handlehash = g_hash_table_new(g_int64_hash, g_int64_equal); struct nbd_reply rep; READ_ALL_ERRCHK(sock, &rep, sizeof(struct nbd_reply), err_open, "Could not read from server socket: %s", strerror(errno)); [...] prc = g_hash_table_lookup(handlehash, rep.handle); So alignof(struct nbd_reply) is 4, and rep.handle is not always 8-byte aligned. Either the handle should be made a uint64_t, or the test should do uint64_t handle; memcpy(&handle, &rep.handle, 8); prc = g_hash_table_lookup(handlehash, &handle); Cheers, Julien
signature.asc
Description: Digital signature