]> git.ozlabs.org Git - petitboot/commitdiff
discover: load_url_async callback should take an int status
authorJeremy Kerr <jk@ozlabs.org>
Tue, 24 Sep 2013 02:39:03 +0000 (10:39 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 25 Sep 2013 06:56:56 +0000 (14:56 +0800)
We don't need a pointer here, just the status value.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/boot.c
discover/paths.c
discover/paths.h

index a1e20e64914aac26a7dce5af50fa1c8deed99179..18bca58576d68b18e2dd3595cf7bf9ab08fdc4d1 100644 (file)
@@ -287,7 +287,7 @@ static void run_boot_hooks(struct boot_task *task)
        free(hooks);
 }
 
-static void boot_process(void *ctx, int *status)
+static void boot_process(void *ctx, int status __attribute__((unused)))
 {
        struct boot_task *task = ctx;
        unsigned int clean_image = 0;
@@ -307,7 +307,6 @@ static void boot_process(void *ctx, int *status)
                        goto no_load;
                } else {
                        task->state = BOOT_STATE_IMAGE_LOADING;
-                       *status = 0;
                        return;
                }
        }
@@ -325,7 +324,6 @@ static void boot_process(void *ctx, int *status)
                                goto no_load;
                        } else {
                                task->state = BOOT_STATE_INITRD_LOADING;
-                               *status = 0;
                                return;
                        }
                } else {
@@ -347,7 +345,6 @@ static void boot_process(void *ctx, int *status)
                                goto no_load;
                        } else {
                                task->state = BOOT_STATE_FINISH;
-                               *status = 0;
                                return;
                        }
                } else {
@@ -357,7 +354,6 @@ static void boot_process(void *ctx, int *status)
 
        if (task->state != BOOT_STATE_FINISH) {
                task->state = BOOT_STATE_UNKNOWN;
-               *status = -1;
                return;
        }
 
@@ -396,8 +392,6 @@ no_load:
        }
 
        talloc_free(task);
-
-       *status = result;
 }
 
 int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd,
@@ -406,7 +400,6 @@ int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd,
        struct boot_task *boot_task;
        struct pb_url *image = NULL;
        const char *boot_desc;
-       int result;
 
        if (opt && opt->option->name)
                boot_desc = opt->option->name;
@@ -457,7 +450,7 @@ int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd,
                boot_task->args = NULL;
        }
 
-       boot_process(boot_task, &result);
+       boot_process(boot_task, 0);
 
-       return result;
+       return 0;
 }
index a1f65ec10a03dfa68a7c6f7765b9f5e97d8cc4b5..dbdf16e51628fc0cf9a8725ae2f422ee7e6db549 100644 (file)
@@ -17,7 +17,6 @@
 struct load_url_async_data {
        load_url_callback url_cb;
        void *ctx;
-       int status;
 };
 
 const char *mount_base(void)
@@ -62,8 +61,7 @@ static void load_url_exit_cb(struct process *process)
        pb_log("The download client '%s' [pid %d] exited, rc %d\n",
                        process->path, process->pid, process->exit_status);
 
-       if (!url_data->status)
-               url_data->url_cb(url_data->ctx, &(url_data->status));
+       url_data->url_cb(url_data->ctx, process->exit_status);
 
        process_release(process);
 }
@@ -362,7 +360,6 @@ char *load_url_async(void *ctx, struct pb_url *url, unsigned int *tempfile,
                url_data = talloc_zero(ctx, struct load_url_async_data);
                url_data->url_cb = url_cb;
                url_data->ctx = ctx;
-               url_data->status = 0;
        }
 
        switch (url->scheme) {
index 93788e9d863fb7331535fcbec97df3ae72edb192..2f52e8245bea81efa040fefc8bb0803ecf907163 100644 (file)
@@ -16,7 +16,7 @@ char *join_paths(void *alloc_ctx, const char *a, const char *b);
  */
 const char *mount_base(void);
 
-typedef void (*load_url_callback)(void *data, int *status);
+typedef void (*load_url_callback)(void *data, int status);
 
 /* Load a (potentially remote) file, and return a guaranteed-local name */
 char *load_url_async(void *ctx, struct pb_url *url, unsigned int *tempfile,