Skip to content

Commit d430809

Browse files
committed
Differentiate LIBAVRDUDE_EXIT_FAIL and ..._EXIT_OK
LIBAVRDUDE_EXIT was introduced to allow driver function to tell main.c that all is done and avrdude should exit(0) indicating success. For example, processing the -x help options in the driver should exit. There have been increasingly more situations when the driver function needed to return and suppress error messages from the caller; for these LIBAVRDUDE_EXIT was used but now avrdude wrongly indicated success to the shell when it should indicate an error. This commit replaces LIBAVRDUDE_EXIT with LIBAVRDUDE_EXIT_FAIL or LIBAVRDUDE_EXIT_OK as appropriate indicating error or success to the shell, respectively.
1 parent 6350272 commit d430809

28 files changed

+61
-61
lines changed

src/arduino.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
5656

5757
if(str_eq(extended_param, "help")) {
5858
help = true;
59-
rv = LIBAVRDUDE_EXIT;
59+
rv = LIBAVRDUDE_EXIT_OK;
6060
}
6161

6262
if(!help) {

src/avr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ int avr_read_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, con
471471
if(pgm->read_sig_bytes) {
472472
int rc = pgm->read_sig_bytes(pgm, p, mem);
473473

474-
if(rc < 0 && rc != LIBAVRDUDE_EXIT)
474+
if(rc < 0 && rc != LIBAVRDUDE_EXIT_OK)
475475
led_set(pgm, LED_ERR);
476476
led_clr(pgm, LED_PGM);
477477
return rc;
@@ -1216,13 +1216,13 @@ int avr_signature(const PROGRAMMER *pgm, const AVRPART *p) {
12161216
if(verbose > 1)
12171217
report_progress(0, 1, "Reading");
12181218
rc = avr_read(pgm, p, "signature", 0);
1219-
if(rc < LIBAVRDUDE_SUCCESS && rc != LIBAVRDUDE_EXIT) {
1219+
if(rc < LIBAVRDUDE_SUCCESS && rc != LIBAVRDUDE_EXIT_OK) {
12201220
pmsg_error("unable to read signature data for part %s (rc = %d)\n", p->desc, rc);
12211221
return rc;
12221222
}
12231223
report_progress(1, 1, NULL);
12241224

1225-
return rc < LIBAVRDUDE_SUCCESS? LIBAVRDUDE_EXIT: LIBAVRDUDE_SUCCESS;
1225+
return rc < LIBAVRDUDE_SUCCESS? LIBAVRDUDE_EXIT_OK: LIBAVRDUDE_SUCCESS;
12261226
}
12271227

12281228
// Obtain bitmask for byte in memory (classic, TPI, PDI and UPDI parts)

src/avr910.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int avr910_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
303303
}
304304
if(str_eq(extended_param, "help")) {
305305
help = true;
306-
rv = LIBAVRDUDE_EXIT;
306+
rv = LIBAVRDUDE_EXIT_OK;
307307
}
308308

309309
if(!help) {

src/avrftdi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ static int avrftdi_jtag_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
13481348

13491349
pmsg_error("programmer type %s is known not to work for %s\n", pgm->type, p->desc);
13501350
pmsg_error("exiting, use -F to carry on regardless\n");
1351-
return LIBAVRDUDE_EXIT;
1351+
return LIBAVRDUDE_EXIT_FAIL;
13521352
}
13531353
}
13541354

src/buspirate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
395395

396396
if(str_eq(extended_param, "help")) {
397397
help = true;
398-
rv = LIBAVRDUDE_EXIT;
398+
rv = LIBAVRDUDE_EXIT_OK;
399399
}
400400

401401
if(!help) {

src/butterfly.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
640640

641641
if(str_eq(extended_param, "help")) {
642642
help = true;
643-
rv = LIBAVRDUDE_EXIT;
643+
rv = LIBAVRDUDE_EXIT_OK;
644644
}
645645

646646
if(!help) {

src/dryrun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ static int dryrun_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) {
10161016
}
10171017
if(str_eq(xpara, "help")) {
10181018
help = true;
1019-
rc = LIBAVRDUDE_EXIT;
1019+
rc = LIBAVRDUDE_EXIT_OK;
10201020
}
10211021

10221022
if(!help) {

src/flip2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ static int flip2_parseexitspecs(PROGRAMMER *pgm, const char *sp) {
484484
}
485485
if(str_eq(cp, "help")) {
486486
help = true;
487-
rv = LIBAVRDUDE_EXIT;
487+
rv = LIBAVRDUDE_EXIT_OK;
488488
}
489489

490490
if(!help) {

src/jtag3.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,8 +1585,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
15851585
continue;
15861586
}
15871587
// Flag a switch to PIC mode
1588-
if(str_caseeq(extended_param, "mode=pic") ||
1589-
str_caseeq(extended_param, "mode=mplab")) {
1588+
if(str_caseeq(extended_param, "mode=mplab") || str_caseeq(extended_param, "mode=pic")) {
15901589
my.pk4_snap_mode = PK4_SNAP_MODE_PIC;
15911590
continue;
15921591
}
@@ -1597,7 +1596,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
15971596

15981597
if(str_eq(extended_param, "help")) {
15991598
help = true;
1600-
rv = LIBAVRDUDE_EXIT;
1599+
rv = LIBAVRDUDE_EXIT_OK;
16011600
}
16021601

16031602
if(!help) {
@@ -1738,7 +1737,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port, int mode_switch) {
17381737
imsg_error("$ %s -c pickit4_mplab%s%s%s -P %s\n", progname, pgm_suffix, partsdesc_flag, partsdesc_str, port);
17391738
}
17401739
serial_close(&pgm->fd);
1741-
return LIBAVRDUDE_EXIT;;
1740+
return LIBAVRDUDE_EXIT_FAIL;
17421741
}
17431742
}
17441743
}
@@ -1787,7 +1786,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port, int mode_switch) {
17871786
}
17881787
msg_error("MPLAB mode switch successful\n");
17891788
serial_close(&pgm->fd);
1790-
return LIBAVRDUDE_EXIT;;
1789+
return LIBAVRDUDE_EXIT_OK;
17911790
}
17921791

17931792
return 0;

src/jtagmkII.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
13621362

13631363
if(str_eq(extended_param, "help")) {
13641364
help = true;
1365-
rv = LIBAVRDUDE_EXIT;
1365+
rv = LIBAVRDUDE_EXIT_OK;
13661366
}
13671367

13681368
if(!help) {
@@ -2674,7 +2674,7 @@ static int jtagmkII_reset32(const PROGRAMMER *pgm, unsigned short flags) {
26742674

26752675
status = jtagmkII_recv(pgm, &resp);
26762676
if(status != 2 || resp[0] != 0x87 || resp[1] != 01)
2677-
gotoerr;;
2677+
gotoerr;
26782678
}
26792679

26802680
if(flags & (AVR32_RESET_WRITE | AVR32_SET4RUNNING)) {

0 commit comments

Comments
 (0)