Submitted by Andrew D'Addesio:

bug #58078: [PATCH] buspirate: remove compound literals (fixes GCC>=9)
* buspirate.c (buspirate_start_mode_bin):
avoid propagating local scope compound literals



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1455 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2021-11-06 22:34:29 +00:00
parent e074edf4cb
commit 60f5885849
3 changed files with 29 additions and 25 deletions

View File

@ -1,3 +1,10 @@
2021-11-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Andrew D'Addesio:
bug #58078: [PATCH] buspirate: remove compound literals (fixes GCC>=9)
* buspirate.c (buspirate_start_mode_bin):
avoid propagating local scope compound literals
2021-11-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2021-11-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Jan Egil Ruud: Submitted by Jan Egil Ruud:

1
NEWS
View File

@ -55,6 +55,7 @@ Current:
no-id: efuse section on ATmega32M1 lacks 'size' no-id: efuse section on ATmega32M1 lacks 'size'
bug #60753: Patch #1436 breaks multiple programmer/device combinations on MacOS BigSur bug #60753: Patch #1436 breaks multiple programmer/device combinations on MacOS BigSur
bug #59525: Bogus error message because Copy/Paste typo in stk500.c bug #59525: Bogus error message because Copy/Paste typo in stk500.c
bug #58078: [PATCH] buspirate: remove compound literals (fixes GCC>=9)
* Patches: * Patches:
patch #9482: Add support for UPDI and AVR8X patch #9482: Add support for UPDI and AVR8X

View File

@ -493,35 +493,31 @@ static void buspirate_reset_from_binmode(struct programmer_t *pgm)
static int buspirate_start_mode_bin(struct programmer_t *pgm) static int buspirate_start_mode_bin(struct programmer_t *pgm)
{ {
const struct submode { struct submode {
const char *name; /* Name of mode for user messages */ const char *name; /* Name of mode for user messages */
char enter; /* Command to enter from base binary mode */ char enter; /* Command to enter from base binary mode */
const char *entered_format; /* Response, for "scanf" */ const char *entered_format; /* Response, for "scanf" */
char config; /* Command to setup submode parameters */ char config; /* Command to setup submode parameters */
} *submode; } submode;
if (pgm->flag & BP_FLAG_XPARM_RAWFREQ) { if (pgm->flag & BP_FLAG_XPARM_RAWFREQ) {
submode = &(const struct submode){ submode.name = "Raw-wire";
.name = "Raw-wire", submode.enter = 0x05;
.enter = 0x05, submode.entered_format = "RAW%1d";
.entered_format = "RAW%1d", submode.config = 0x8C;
.config = 0x8C,
};
pgm->flag |= BP_FLAG_NOPAGEDWRITE; pgm->flag |= BP_FLAG_NOPAGEDWRITE;
pgm->flag |= BP_FLAG_NOPAGEDREAD; pgm->flag |= BP_FLAG_NOPAGEDREAD;
} else { } else {
submode = &(const struct submode){ submode.name = "SPI";
.name = "SPI", submode.enter = 0x01;
.enter = 0x01, submode.entered_format = "SPI%1d";
.entered_format = "SPI%1d",
/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample * we want: 3.3V(1), idle low(0), data change on
* we want: 3.3V(1), idle low(0), data change on * trailing edge (1), sample in the middle
* trailing edge (1), sample in the middle * of the pulse (0)
* of the pulse (0) * => 0b10001010 = 0x8a */
* => 0b10001010 = 0x8a */ submode.config = 0x8A;
.config = 0x8A,
};
} }
unsigned char buf[20] = { '\0' }; unsigned char buf[20] = { '\0' };
@ -566,18 +562,18 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
} }
/* == Set protocol sub-mode of binary mode == */ /* == Set protocol sub-mode of binary mode == */
buf[0] = submode->enter; buf[0] = submode.enter;
buspirate_send_bin(pgm, buf, 1); buspirate_send_bin(pgm, buf, 1);
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
buspirate_recv_bin(pgm, buf, 4); buspirate_recv_bin(pgm, buf, 4);
if (sscanf((const char*)buf, submode->entered_format, &PDATA(pgm)->submode_version) != 1) { if (sscanf((const char*)buf, submode.entered_format, &PDATA(pgm)->submode_version) != 1) {
avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n", avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n",
submode->name, buf); submode.name, buf);
buspirate_reset_from_binmode(pgm); buspirate_reset_from_binmode(pgm);
return -1; return -1;
} }
avrdude_message(MSG_NOTICE, "BusPirate %s version: %d\n", avrdude_message(MSG_NOTICE, "BusPirate %s version: %d\n",
submode->name, PDATA(pgm)->submode_version); submode.name, PDATA(pgm)->submode_version);
if (pgm->flag & BP_FLAG_NOPAGEDWRITE) { if (pgm->flag & BP_FLAG_NOPAGEDWRITE) {
avrdude_message(MSG_NOTICE, "%s: Paged flash write disabled.\n", progname); avrdude_message(MSG_NOTICE, "%s: Paged flash write disabled.\n", progname);
@ -618,7 +614,7 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
return -1; return -1;
/* Submode config */ /* Submode config */
if (buspirate_expect_bin_byte(pgm, submode->config, 0x01) < 0) if (buspirate_expect_bin_byte(pgm, submode.config, 0x01) < 0)
return -1; return -1;
/* AVR Extended Commands - test for existence */ /* AVR Extended Commands - test for existence */