From: Antonio Ospite Date: Wed, 14 Nov 2012 11:01:34 +0000 (+0100) Subject: am7xxx: assign device_list next to its first use X-Git-Tag: v0.1.3~10 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/c8837a57134230c335a85da22322fd794b19ff44?ds=inline am7xxx: assign device_list next to its first use This makes the code a little more readable. --- diff --git a/src/am7xxx.c b/src/am7xxx.c index 08858cd..47e04bb 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -453,8 +453,6 @@ static am7xxx_device *add_new_device(am7xxx_context *ctx) return NULL; } - devices_list = &(ctx->devices_list); - new_device = malloc(sizeof(*new_device)); if (new_device == NULL) { fatal("cannot allocate a new device (%s)\n", strerror(errno)); @@ -464,6 +462,8 @@ static am7xxx_device *add_new_device(am7xxx_context *ctx) new_device->ctx = ctx; + devices_list = &(ctx->devices_list); + if (*devices_list == NULL) { *devices_list = new_device; } else {