Silence sign-compare warnings in pgm_type.c and clean up
This commit is contained in:
parent
e089d7ecc5
commit
aa258ace36
|
@ -111,29 +111,17 @@ const PROGRAMMER_TYPE programmers_types[] = { // Name(s) the programmers call th
|
||||||
{"xbee", xbee_initpgm, xbee_desc}, // "XBee"
|
{"xbee", xbee_initpgm, xbee_desc}, // "XBee"
|
||||||
};
|
};
|
||||||
|
|
||||||
const PROGRAMMER_TYPE * locate_programmer_type(const char * id)
|
const PROGRAMMER_TYPE *locate_programmer_type(const char *id) {
|
||||||
{
|
for(size_t i = 0; i < sizeof programmers_types/sizeof*programmers_types; i++)
|
||||||
const PROGRAMMER_TYPE * p = NULL;
|
if(strcasecmp(id, programmers_types[i].id) == 0)
|
||||||
int i;
|
return programmers_types + i;
|
||||||
int found;
|
|
||||||
|
|
||||||
found = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]) && !found; i++) {
|
|
||||||
p = &(programmers_types[i]);
|
|
||||||
if (strcasecmp(id, p->id) == 0)
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found)
|
|
||||||
return p;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return type id given the init function or "" if not found
|
// Return type id given the init function or "" if not found
|
||||||
const char *locate_programmer_type_id(void (*initpgm)(PROGRAMMER *pgm)) {
|
const char *locate_programmer_type_id(void (*initpgm)(PROGRAMMER *pgm)) {
|
||||||
for (int i=0; i < sizeof programmers_types/sizeof*programmers_types; i++)
|
for(size_t i=0; i < sizeof programmers_types/sizeof*programmers_types; i++)
|
||||||
if(programmers_types[i].initpgm == initpgm)
|
if(programmers_types[i].initpgm == initpgm)
|
||||||
return programmers_types[i].id;
|
return programmers_types[i].id;
|
||||||
|
|
||||||
|
@ -142,35 +130,15 @@ const char *locate_programmer_type_id(void (*initpgm)(PROGRAMMER *pgm)) {
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the list of programmers given as "programmers", and
|
* Iterate over the list of programmer types given in the table above and
|
||||||
* call the callback function cb for each entry found. cb is being
|
* call the callback function cb for each entry found. cb is being
|
||||||
* passed the following arguments:
|
* passed the following arguments:
|
||||||
* . the name of the programmer (for -c)
|
* - Name of the programmer
|
||||||
* . the descriptive text given in the config file
|
* - Descriptive text
|
||||||
* . the name of the config file this programmer has been defined in
|
* - "Cookie" passed into walk_programmer_types() for opaque client data
|
||||||
* . the line number of the config file this programmer has been defined at
|
|
||||||
* . the "cookie" passed into walk_programmers() (opaque client data)
|
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
void walk_programmer_types(LISTID programmer_types, walk_programmer_types_cb cb, void *cookie)
|
|
||||||
{
|
|
||||||
LNODEID ln1;
|
|
||||||
PROGRAMMER * p;
|
|
||||||
|
|
||||||
for (ln1 = lfirst(programmers); ln1; ln1 = lnext(ln1)) {
|
void walk_programmer_types(walk_programmer_types_cb cb, void *cookie) {
|
||||||
p = ldata(ln1);
|
for (size_t i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]); i++)
|
||||||
cb(p->id, p->desc, cookie);
|
cb(programmers_types[i].id, programmers_types[i].desc, cookie);
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void walk_programmer_types(walk_programmer_types_cb cb, void *cookie)
|
|
||||||
{
|
|
||||||
const PROGRAMMER_TYPE * p;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]); i++) {
|
|
||||||
p = &(programmers_types[i]);
|
|
||||||
cb(p->id, p->desc, cookie);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue