Skip to content

Commit

Permalink
Test programmers for prog_modes and type
Browse files Browse the repository at this point in the history
This corrects the error message when AVRDUDE cannot use a programmer to
say it is owing to lack of prog_modes or type.
  • Loading branch information
stefanrueger committed Nov 3, 2023
1 parent 08b82ea commit cf4285f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,15 @@ static int dev_opt(const char *str) {
}


static void programmer_not_found(const char *programmer) {
static void programmer_not_found(const char *programmer, PROGRAMMER *pgm) {
msg_error("\n");
if(programmer && *programmer)
pmsg_error("cannot find programmer id %s\n", programmer);
else {
if(programmer && *programmer) {
if(!pgm || !pgm->id || !lsize(pgm->id))
pmsg_error("cannot find programmer id %s\n", programmer);
else
pmsg_error("programmer %s lacks %s setting\n", programmer,
!pgm->prog_modes? "prog_modes": !pgm->initpgm? "type": "some");
} else {
pmsg_error("no programmer has been specified on the command line or in the\n");
imsg_error("config file(s); specify one using the -c option and try again\n");
}
Expand Down Expand Up @@ -1057,7 +1061,7 @@ int main(int argc, char * argv [])
if(pgmid && *pgmid && explicit_c) {
PROGRAMMER *pgm = locate_programmer_set(programmers, pgmid, &pgmid);
if(!pgm || !is_programmer(pgm)) {
programmer_not_found(pgmid);
programmer_not_found(pgmid, pgm);
exit(1);
}
msg_error("\nValid parts for programmer %s are:\n", pgmid);
Expand Down Expand Up @@ -1100,13 +1104,13 @@ int main(int argc, char * argv [])
msg_notice("\n");

if(!pgmid || !*pgmid) {
programmer_not_found(NULL);
programmer_not_found(NULL, NULL);
exit(1);
}

pgm = locate_programmer_set(programmers, pgmid, &pgmid);
if (pgm == NULL || !is_programmer(pgm)) {
programmer_not_found(pgmid);
programmer_not_found(pgmid, pgm);
exit(1);
}

Expand Down

0 comments on commit cf4285f

Please sign in to comment.