transfused: use memcmp instead of a loop for checking init message

Signed-off-by: David Sheets <dsheets@docker.com>
This commit is contained in:
David Sheets 2016-12-14 16:20:29 +00:00
parent 9d5309953f
commit 58706fd84e

View File

@ -938,10 +938,9 @@ void *init_thread(void *params_ptr)
buf = must_malloc("incoming control message buffer", CTL_BUFSZ); buf = must_malloc("incoming control message buffer", CTL_BUFSZ);
/* TODO: handle other messages */ /* TODO: handle other messages */
read_exactly("init thread", params->ctl_sock, buf, 6); read_exactly("init thread", params->ctl_sock, buf, sizeof(init_msg));
for (int i = 0; i < sizeof(init_msg); i++) if (memcmp(buf, init_msg, sizeof(init_msg)))
if (((char *)buf)[i] != init_msg[i]) die(1, params, NULL, "init thread: unexpected message");
die(1, params, NULL, "init thread: unexpected message");
/* we've gotten Continue so write the pidfile */ /* we've gotten Continue so write the pidfile */
if (params->pidfile != NULL) if (params->pidfile != NULL)