path: root/ui/common
diff options
authorJeremy Kerr <>2013-03-08 17:04:21 +0800
committerJeremy Kerr <>2013-04-16 11:41:43 +0800
commitb838cf777ed3d21b166f8daddd4b11fc75e07307 (patch)
tree198e3450af8561c3806bd82c30f2daa10566ef70 /ui/common
parent80c072a44cb665495afe08ce37cbf4f2086d5529 (diff)
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 <>
Diffstat (limited to 'ui/common')
1 files changed, 5 insertions, 2 deletions
diff --git a/ui/common/discover-client.c b/ui/common/discover-client.c
index f75cfb7..c0cfea0 100644
--- a/ui/common/discover-client.c
+++ b/ui/common/discover-client.c
@@ -83,6 +83,7 @@ static int discover_client_process(void *arg)
struct pb_protocol_message *message;
struct device *dev;
char *dev_id;
+ int rc;
message = pb_protocol_read_message(client, client->fd);
@@ -91,8 +92,10 @@ static int discover_client_process(void *arg)
switch (message->action) {
- dev = pb_protocol_deserialise_device(client, message);
- if (!dev) {
+ dev = talloc(client, struct device);
+ rc = pb_protocol_deserialise_device(dev, message);
+ if (rc) {
pb_log("%s: no device?\n", __func__);
return 0;
OpenPOWER on IntegriCloud