am7xxx: assign device_list next to its first use
authorAntonio Ospite <ospite@studenti.unina.it>
Wed, 14 Nov 2012 11:01:34 +0000 (12:01 +0100)
committerAntonio Ospite <ospite@studenti.unina.it>
Wed, 14 Nov 2012 11:26:42 +0000 (12:26 +0100)
This makes the code a little more readable.

src/am7xxx.c

index 08858cd..47e04bb 100644 (file)
@@ -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 {