On Sat, 16 Jul 2011 01:06:40 +0200
Carl-Daniel Hailfinger <[email protected]> wrote:

> +                     if (find_romentry(tempstr)) {
> +                             fprintf(stderr, "Error: image %s not found in "
> +                                     "layout file or -i specified before "
> +                                     "-l\n", tempstr);
> +                             cli_classic_abort_usage();
> +                     }

find_romentry does return the index of the (first matching) rom entry
(>=0) on success, or -1 on failure:

int find_romentry(char *name)
{
        int i;

        if (!romimages)
                return -1;

        msg_ginfo("Looking for \"%s\"... ", name);

        for (i = 0; i < romimages; i++) {
                if (!strcmp(rom_entries[i].name, name)) {
                        rom_entries[i].included = 1;
                        msg_ginfo("found.\n");
                        return i;
                }
        }
        msg_ginfo("not found.\n");      // Not found. Error.

        return -1;
}

the attached patch fixes this. thanks to Florian Zumbiehl for reporting
this (http://paste.flashrom.org/view.php?id=707).

carldani: you wrote you did not fix the -l/-i ordering problem "because
the new layout code may have different requirements anyway".
the first step to fix this is to extract the needed file and region
names from the command line (to use them after the parsing loop has
finished). this is somewhat independent from whatever we do with the
arguments then. if you agree i would like to fix this now (i did not
look for what is needed exactly yet), if not you can just ack the patch.

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
>From 754fc0cf0b44d5e7b93e48cdea5e1e4641484b50 Mon Sep 17 00:00:00 2001
From: Stefan Tauner <[email protected]>
Date: Mon, 18 Jul 2011 13:55:01 +0200
Subject: [PATCH] fix a bug breaking layout file handling in r1373


Signed-off-by: Stefan Tauner <[email protected]>
---
 cli_classic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cli_classic.c b/cli_classic.c
index 9168bc1..53cd4a0 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -235,7 +235,7 @@ int cli_classic(int argc, char *argv[])
 		case 'i':
 			/* FIXME: -l has to be specified before -i. */
 			tempstr = strdup(optarg);
-			if (find_romentry(tempstr)) {
+			if (find_romentry(tempstr) < 0) {
 				fprintf(stderr, "Error: image %s not found in "
 					"layout file or -i specified before "
 					"-l\n", tempstr);
-- 
1.7.1

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to