From a93648d197df48fa46dd55f925ff70468bd81c71 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Thu, 15 Jan 2015 02:48:07 -0200 Subject: imagetool: replace image registration function by linker_lists feature The registration was introduced in commit f86ed6a8d52c99bb2d17d3cac1647edca0c4399c This commit also removes all registration functions, and the member "next" from image_type_params struct Signed-off-by: Guilherme Maciel Ferreira --- tools/dumpimage.c | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) (limited to 'tools/dumpimage.c') diff --git a/tools/dumpimage.c b/tools/dumpimage.c index 0228e183ab..80bf583b39 100644 --- a/tools/dumpimage.c +++ b/tools/dumpimage.c @@ -20,41 +20,6 @@ static struct image_tool_params params = { .type = IH_TYPE_KERNEL, }; -/** - * dumpimage_register() - register respective image generation/list support - * - * the input struct image_type_params is checked and appended to the link - * list, if the input structure is already registered, issue an error - * - * @tparams: Image type parameters - */ -static void dumpimage_register(struct image_type_params *tparams) -{ - struct image_type_params **tp; - - if (!tparams) { - fprintf(stderr, "%s: %s: Null input\n", params.cmdname, - __func__); - exit(EXIT_FAILURE); - } - - /* scan the linked list, check for registry and point the last one */ - for (tp = &dumpimage_tparams; *tp != NULL; tp = &(*tp)->next) { - if (!strcmp((*tp)->name, tparams->name)) { - fprintf(stderr, "%s: %s already registered\n", - params.cmdname, tparams->name); - return; - } - } - - /* add input struct entry at the end of link list */ - *tp = tparams; - /* mark input entry as last entry in the link list */ - tparams->next = NULL; - - debug("Registered %s\n", tparams->name); -} - /* * dumpimage_extract_datafile - * @@ -70,8 +35,12 @@ static int dumpimage_extract_datafile(void *ptr, struct stat *sbuf) { int retval = -1; struct image_type_params *curr; + struct image_type_params *start = ll_entry_start( + struct image_type_params, image_type); + struct image_type_params *end = ll_entry_end( + struct image_type_params, image_type); - for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) { + for (curr = start; curr != end; curr++) { if (curr->verify_header) { retval = curr->verify_header((unsigned char *)ptr, sbuf->st_size, ¶ms); @@ -104,9 +73,6 @@ int main(int argc, char **argv) int retval = 0; struct image_type_params *tparams = NULL; - /* Init all image generation/list support */ - register_image_tool(dumpimage_register); - params.cmdname = *argv; while ((opt = getopt(argc, argv, "li:o:p:V")) != -1) { @@ -142,7 +108,7 @@ int main(int argc, char **argv) usage(); /* set tparams as per input type_id */ - tparams = imagetool_get_type(params.type, dumpimage_tparams); + tparams = imagetool_get_type(params.type); if (tparams == NULL) { fprintf(stderr, "%s: unsupported type %s\n", params.cmdname, genimg_get_type_name(params.type)); -- cgit v1.2.1