mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-23 09:36:24 +03:00
rename matches() to str_starts()
The function never checked for an actual match anyways
This commit is contained in:
34
src/jtag3.c
34
src/jtag3.c
@@ -192,7 +192,7 @@ u16_to_b2_big_endian(unsigned char *b, unsigned short l)
|
||||
b[1] = l & 0xff;
|
||||
}
|
||||
|
||||
static bool matches(const char *s, const char *pat)
|
||||
static bool str_starts(const char *s, const char *pat)
|
||||
{
|
||||
return strncmp(s, pat, strlen(pat)) == 0;
|
||||
}
|
||||
@@ -879,7 +879,7 @@ int jtag3_getsync(const PROGRAMMER *pgm, int mode) {
|
||||
/* XplainedMini boards do not need this, and early revisions had a
|
||||
* firmware bug where they complained about it. */
|
||||
if ((pgm->flag & PGM_FL_IS_EDBG) &&
|
||||
!matches(ldata(lfirst(pgm->id)), "xplainedmini")) {
|
||||
!str_starts(ldata(lfirst(pgm->id)), "xplainedmini")) {
|
||||
if (jtag3_edbg_prepare(pgm) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1174,7 +1174,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
u32_to_b4(xd.nvm_boot_offset, m->offset);
|
||||
} else if (strcmp(m->desc, "fuse1") == 0) {
|
||||
u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7);
|
||||
} else if (matches(m->desc, "lock")) {
|
||||
} else if (str_starts(m->desc, "lock")) {
|
||||
u32_to_b4(xd.nvm_lock_offset, m->offset);
|
||||
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||
strcmp(m->desc, "userrow") == 0) {
|
||||
@@ -1457,7 +1457,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
||||
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
|
||||
extended_param = ldata(ln);
|
||||
|
||||
if (matches(extended_param, "jtagchain=") && (pgm->prog_modes & (PM_JTAG | PM_XMEGAJTAG | PM_AVR32JTAG))) {
|
||||
if (str_starts(extended_param, "jtagchain=") && (pgm->prog_modes & (PM_JTAG | PM_XMEGAJTAG | PM_AVR32JTAG))) {
|
||||
unsigned int ub, ua, bb, ba;
|
||||
if (sscanf(extended_param, "jtagchain=%u,%u,%u,%u", &ub, &ua, &bb, &ba) != 4) {
|
||||
pmsg_error("invalid JTAG chain '%s'\n", extended_param);
|
||||
@@ -1486,10 +1486,10 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
||||
// Bit 2 EOF: Agressive power-down, sleep after 5 seconds if no USB enumeration when set to 0
|
||||
// Bit 1 LOWP: forces running at 1 MHz when bit set to 0
|
||||
// Bit 0 FUSE: Fuses are safe-masked when bit sent to 1 Fuses are unprotected when set to 0
|
||||
else if (matches(extended_param, "suffer") ) {
|
||||
else if (str_starts(extended_param, "suffer") ) {
|
||||
if(pgm->extra_features & HAS_SUFFER) {
|
||||
// Set SUFFER value
|
||||
if (matches(extended_param, "suffer=")) {
|
||||
if (str_starts(extended_param, "suffer=")) {
|
||||
if (sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
|
||||
pmsg_error("invalid -xsuffer=<value> '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
@@ -1509,10 +1509,10 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
||||
}
|
||||
}
|
||||
|
||||
else if (matches(extended_param, "vtarg_switch") ) {
|
||||
else if (str_starts(extended_param, "vtarg_switch") ) {
|
||||
if(pgm->extra_features & HAS_VTARG_SWITCH) {
|
||||
// Set Vtarget switch value
|
||||
if (matches(extended_param, "vtarg_switch=")) {
|
||||
if (str_starts(extended_param, "vtarg_switch=")) {
|
||||
int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
|
||||
if (sscanf_success < 1 || PDATA(pgm)->vtarg_switch_data[1] > 1) {
|
||||
pmsg_error("invalid vtarg_switch value '%s'\n", extended_param);
|
||||
@@ -1545,7 +1545,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port) {
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if (!matches(port, "usb")) {
|
||||
if (!str_starts(port, "usb")) {
|
||||
pmsg_error("JTAGICE3/EDBG port names must start with usb\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -1598,7 +1598,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port) {
|
||||
if (rv < 0) {
|
||||
// Check if SNAP or PICkit4 is in PIC mode
|
||||
for(LNODEID ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
|
||||
if (matches(ldata(ln), "snap")) {
|
||||
if (str_starts(ldata(ln), "snap")) {
|
||||
pinfo.usbinfo.vid = USB_VENDOR_MICROCHIP;
|
||||
pinfo.usbinfo.pid = USB_DEVICE_SNAP_PIC_MODE;
|
||||
int pic_mode = serial_open(port, pinfo, &pgm->fd);
|
||||
@@ -1613,7 +1613,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port) {
|
||||
imsg_error("Use MPLAB X or Microchip Studio to switch to AVR mode\n\n");
|
||||
return -1;
|
||||
}
|
||||
} else if(matches(ldata(ln), "pickit4")) {
|
||||
} else if(str_starts(ldata(ln), "pickit4")) {
|
||||
pinfo.usbinfo.vid = USB_VENDOR_MICROCHIP;
|
||||
pinfo.usbinfo.pid = USB_DEVICE_PICKIT4_PIC_MODE;
|
||||
int pic_mode = serial_open(port, pinfo, &pgm->fd);
|
||||
@@ -1745,7 +1745,7 @@ void jtag3_close(PROGRAMMER * pgm) {
|
||||
/* XplainedMini boards do not need this, and early revisions had a
|
||||
* firmware bug where they complained about it. */
|
||||
if ((pgm->flag & PGM_FL_IS_EDBG) &&
|
||||
!matches(ldata(lfirst(pgm->id)), "xplainedmini")) {
|
||||
!str_starts(ldata(lfirst(pgm->id)), "xplainedmini")) {
|
||||
jtag3_edbg_signoff(pgm);
|
||||
}
|
||||
|
||||
@@ -2050,11 +2050,11 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
||||
addr = 2;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
} else if (matches(mem->desc, "lock")) {
|
||||
} else if (str_starts(mem->desc, "lock")) {
|
||||
cmd[3] = MTYPE_LOCK_BITS;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
} else if (matches(mem->desc, "fuse")) {
|
||||
} else if (str_starts(mem->desc, "fuse")) {
|
||||
cmd[3] = MTYPE_FUSE_BITS;
|
||||
if (!(p->prog_modes & PM_UPDI))
|
||||
addr = mem->offset & 7;
|
||||
@@ -2213,7 +2213,7 @@ static int jtag3_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
||||
addr = 2;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
} else if (matches(mem->desc, "fuse")) {
|
||||
} else if (str_starts(mem->desc, "fuse")) {
|
||||
cmd[3] = MTYPE_FUSE_BITS;
|
||||
if (!(p->prog_modes & PM_UPDI))
|
||||
addr = mem->offset & 7;
|
||||
@@ -2222,7 +2222,7 @@ static int jtag3_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
||||
cmd[3] = MTYPE_USERSIG;
|
||||
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
||||
cmd[3] = MTYPE_PRODSIG;
|
||||
} else if (matches(mem->desc, "lock")) {
|
||||
} else if (str_starts(mem->desc, "lock")) {
|
||||
cmd[3] = MTYPE_LOCK_BITS;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
@@ -2494,7 +2494,7 @@ void jtag3_print_parms1(const PROGRAMMER *pgm, const char *p, FILE *fp) {
|
||||
|
||||
// Print features unique to the Power Debugger
|
||||
for(LNODEID ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
|
||||
if(matches(ldata(ln), "powerdebugger")) {
|
||||
if(str_starts(ldata(ln), "powerdebugger")) {
|
||||
short analog_raw_data;
|
||||
|
||||
// Read generator set voltage value (VOUT)
|
||||
|
||||
Reference in New Issue
Block a user