Changeset 1523 for trunk/layout.c


Ignore:
Timestamp:
Apr 15, 2012, 4:09:16 PM (2 years ago)
Author:
stefanct
Message:

Check for duplicate -i arguments.

And a tiny cleanup.

Signed-off-by: Stefan Tauner <stefan.tauner@…>
Acked-by: Uwe Hermann <uwe@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/layout.c

    r1483 r1523  
    202202#endif 
    203203 
     204/* returns the index of the entry (or a negative value if it is not found) */ 
     205int find_include_arg(const char *const name) 
     206{ 
     207        unsigned int i; 
     208        for (i = 0; i < num_include_args; i++) { 
     209                if (!strcmp(include_args[i], name)) 
     210                        return i; 
     211        } 
     212        return -1; 
     213} 
     214 
    204215/* register an include argument (-i) for later processing */ 
    205216int register_include_arg(char *name) 
     
    212223        if (name == NULL) { 
    213224                msg_gerr("<NULL> is a bad region name.\n"); 
     225                return 1; 
     226        } 
     227 
     228        if (find_include_arg(name) != -1) { 
     229                msg_gerr("Duplicate region name: \"%s\".\n", name); 
    214230                return 1; 
    215231        } 
     
    251267                return 0; 
    252268 
     269        /* User has specified an area, but no layout file is loaded. */ 
     270        if (!romimages) { 
     271                msg_gerr("Region requested (with -i \"%s\"), " 
     272                         "but no layout data is available.\n", 
     273                         include_args[0]); 
     274                return 1; 
     275        } 
     276 
    253277        for (i = 0; i < num_include_args; i++) { 
    254                 /* User has specified an area, but no layout file is loaded. */ 
    255                 if (!romimages) { 
    256                         msg_gerr("Region requested (with -i \"%s\"), " 
    257                                  "but no layout data is available.\n", 
    258                                  include_args[i]); 
    259                         return 1; 
    260                 } 
    261  
    262278                if (find_romentry(include_args[i]) < 0) { 
    263                         msg_gerr("Invalid region specified: \"%s\"\n", 
     279                        msg_gerr("Invalid region specified: \"%s\".\n", 
    264280                                 include_args[i]); 
    265281                        return 1; 
Note: See TracChangeset for help on using the changeset viewer.