From b838cf777ed3d21b166f8daddd4b11fc75e07307 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Fri, 8 Mar 2013 17:04:21 +0800 Subject: pb-protocol: Don't allocate in deserialise functions Curently, the protocol deserialise functions are allocating device and boot_command structures. This (implicitly) makes them responsible for initialisation of these structures too. Rather that making the protocol responsible for initialising the devices and boot commands, this change gives the deserialise functions an argument to an already-instanciated structure. This means that the creation is no longer implied by the deserialise. Signed-off-by: Jeremy Kerr --- discover/discover-server.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'discover/discover-server.c') diff --git a/discover/discover-server.c b/discover/discover-server.c index 6c80372..9ec3382 100644 --- a/discover/discover-server.c +++ b/discover/discover-server.c @@ -132,6 +132,7 @@ static int discover_server_process_message(void *arg) struct pb_protocol_message *message; struct boot_command *boot_command; struct client *client = arg; + int rc; message = pb_protocol_read_message(client, client->fd); @@ -143,8 +144,10 @@ static int discover_server_process_message(void *arg) return 0; } - boot_command = pb_protocol_deserialise_boot_command(client, message); - if (!boot_command) { + boot_command = talloc(client, struct boot_command); + + rc = pb_protocol_deserialise_boot_command(boot_command, message); + if (rc) { pb_log("%s: no boot command?", __func__); return 0; } -- cgit v1.2.1