• R/O
  • SSH
  • HTTPS

avrdude: Commit


Commit MetaInfo

Revision1468 (tree)
Zeit2020-02-17 03:57:24
Autorgottfried

Log Message

usbpid from LNODEID -> std::vector

Ändern Zusammenfassung

Diff

--- trunk/avrftdi.cpp (revision 1467)
+++ trunk/avrftdi.cpp (revision 1468)
@@ -668,14 +668,19 @@
668668 else
669669 vid = USB_VENDOR_FTDI;
670670
671- LNODEID usbpid = lfirst(pgm->usbpid);
672- if (usbpid) {
673- pid = *(int *)(ldata(usbpid));
674- if (lnext(usbpid))
675- avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
671+ if(pgm->usbpid.size())
672+ {
673+ pid = pgm->usbpid[0];
674+ if(pgm->usbpid.size() > 1)
675+ {
676+ avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
676677 progname, pid);
677- } else
678- pid = USB_DEVICE_FT2232;
678+ }
679+ }
680+ else
681+ {
682+ pid = USB_DEVICE_FT2232;
683+ }
679684
680685 if (0 == pgm->usbsn[0]) /* we don't care about SN. Use first avail. */
681686 serial = NULL;
--- trunk/config_gram.y (revision 1467)
+++ trunk/config_gram.y (revision 1468)
@@ -564,25 +564,18 @@
564564 TKN_NUMBER {
565565 {
566566 /* overwrite pids, so clear the existing entries */
567- ldestroy_cb(current_prog->usbpid, free);
568- current_prog->usbpid = lcreat(NULL, 0);
567+ current_prog->usbpid.clear();
569568 }
570569 {
571- int *ip = static_cast<int*>(malloc(sizeof(int)));
572- if (ip) {
573- *ip = $1->value.number;
574- ladd(current_prog->usbpid, ip);
575- }
570+ int ip = $1->value.number;
571+ current_prog->usbpid.push_back(ip);
576572 free_token($1);
577573 }
578574 } |
579575 usb_pid_list TKN_COMMA TKN_NUMBER {
580576 {
581- int *ip = static_cast<int*>(malloc(sizeof(int)));
582- if (ip) {
583- *ip = $3->value.number;
584- ladd(current_prog->usbpid, ip);
585- }
577+ int ip = $3->value.number;
578+ current_prog->usbpid.push_back(ip);
586579 free_token($3);
587580 }
588581 }
--- trunk/flip1.cpp (revision 1467)
+++ trunk/flip1.cpp (revision 1468)
@@ -234,13 +234,17 @@
234234 */
235235
236236 vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL;
237- LNODEID usbpid = lfirst(pgm->usbpid);
238- if (usbpid) {
239- pid = *(int *)(ldata(usbpid));
240- if (lnext(usbpid))
237+ if(pgm->usbpid.size())
238+ {
239+ pid = pgm->usbpid[0];
240+ if(pgm->usbpid.size() > 1)
241+ {
241242 avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
242243 progname, pid);
243- } else {
244+ }
245+ }
246+ else
247+ {
244248 pid = part->usbpid;
245249 }
246250 if (!ovsigck && (part->flags & AVRPART_HAS_PDI)) {
--- trunk/flip2.cpp (revision 1467)
+++ trunk/flip2.cpp (revision 1468)
@@ -227,13 +227,17 @@
227227 */
228228
229229 vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL;
230- LNODEID usbpid = lfirst(pgm->usbpid);
231- if (usbpid) {
232- pid = *(int *)(ldata(usbpid));
233- if (lnext(usbpid))
230+ if(pgm->usbpid.size())
231+ {
232+ pid = pgm->usbpid[0];
233+ if(pgm->usbpid.size() > 1)
234+ {
234235 avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
235236 progname, pid);
236- } else {
237+ }
238+ }
239+ else
240+ {
237241 pid = part->usbpid;
238242 }
239243
--- trunk/jtag3.cpp (revision 1467)
+++ trunk/jtag3.cpp (revision 1468)
@@ -1416,7 +1416,6 @@
14161416 int jtag3_open_common(PROGRAMMER * pgm, char * port)
14171417 {
14181418 union pinfo pinfo;
1419- LNODEID usbpid;
14201419 int rv = -1;
14211420
14221421 #if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBHIDAPI)
@@ -1424,20 +1423,21 @@
14241423 return -1;
14251424 #endif
14261425
1427- if (strncmp(port, "usb", 3) != 0) {
1426+ if(strncmp(port, "usb", 3) != 0)
1427+ {
14281428 avrdude_message(MSG_INFO, "%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
14291429 progname);
14301430 return -1;
14311431 }
14321432
1433- if (pgm->usbvid)
1433+ if(pgm->usbvid)
14341434 pinfo.usbinfo.vid = pgm->usbvid;
14351435 else
14361436 pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
14371437
14381438 /* If the config entry did not specify a USB PID, insert the default one. */
1439- if (lfirst(pgm->usbpid) == NULL)
1440- ladd(pgm->usbpid, (void *)USB_DEVICE_JTAGICE3);
1439+ if(!pgm->usbpid.size())
1440+ pgm->usbpid.push_back(USB_DEVICE_JTAGICE3);
14411441
14421442 #if defined(HAVE_LIBHIDAPI)
14431443 /*
@@ -1445,9 +1445,11 @@
14451445 * troubles for HID-class devices in some OSes (like Windows).
14461446 */
14471447 serdev = &usbhid_serdev;
1448- for (usbpid = lfirst(pgm->usbpid); rv < 0 && usbpid != NULL; usbpid = lnext(usbpid)) {
1448+ for(std::vector<int>::const_iterator it = pgm->usbpid.begin(); it != pgm->usbpid.end(); ++it)
1449+ {
1450+ int usbpid = *it;
14491451 pinfo.usbinfo.flags = PINFO_FL_SILENT;
1450- pinfo.usbinfo.pid = *(int *)(ldata(usbpid));
1452+ pinfo.usbinfo.pid = usbpid;
14511453 pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
14521454 pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
14531455 pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
@@ -1455,14 +1457,19 @@
14551457
14561458 strcpy(pgm->port, port);
14571459 rv = serial_open(port, pinfo, &pgm->fd);
1460+ if(rv >= 0)
1461+ break;
14581462 }
1459- if (rv < 0) {
1463+ if(rv < 0)
14601464 #endif /* HAVE_LIBHIDAPI */
1465+ {
14611466 #if defined(HAVE_LIBUSB)
14621467 serdev = &usb_serdev_frame;
1463- for (usbpid = lfirst(pgm->usbpid); rv < 0 && usbpid != NULL; usbpid = lnext(usbpid)) {
1468+ for(std::vector<int>::const_iterator it = pgm->usbpid.begin(); it != pgm->usbpid.end(); ++it)
1469+ {
1470+ int usbpid = *it;
14641471 pinfo.usbinfo.flags = PINFO_FL_SILENT;
1465- pinfo.usbinfo.pid = *(int *)(ldata(usbpid));
1472+ pinfo.usbinfo.pid = usbpid;
14661473 pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
14671474 pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
14681475 pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
@@ -1472,17 +1479,18 @@
14721479 rv = serial_open(port, pinfo, &pgm->fd);
14731480 }
14741481 #endif /* HAVE_LIBUSB */
1475-#if defined(HAVE_LIBHIDAPI)
14761482 }
1477-#endif
1478- if (rv < 0) {
1483+ if(rv < 0)
1484+ {
14791485 avrdude_message(MSG_INFO, "%s: jtag3_open_common(): Did not find any device matching VID 0x%04x and PID list: ",
14801486 progname, (unsigned)pinfo.usbinfo.vid);
14811487 int notfirst = 0;
1482- for (usbpid = lfirst(pgm->usbpid); usbpid != NULL; usbpid = lnext(usbpid)) {
1483- if (notfirst)
1488+ for(std::vector<int>::const_iterator it = pgm->usbpid.begin(); it != pgm->usbpid.end(); ++it)
1489+ {
1490+ int usbpid = *it;
1491+ if(notfirst)
14841492 avrdude_message(MSG_INFO, ", ");
1485- avrdude_message(MSG_INFO, "0x%04x", (unsigned int)(*(int *)(ldata(usbpid))));
1493+ avrdude_message(MSG_INFO, "0x%04x", usbpid);
14861494 notfirst = 1;
14871495 }
14881496 fputc('\n', stderr);
@@ -1490,7 +1498,7 @@
14901498 return -1;
14911499 }
14921500
1493- if (pgm->fd.usb.eep == 0)
1501+ if(pgm->fd.usb.eep == 0)
14941502 {
14951503 /* The event EP has been deleted by usb_open(), so we are
14961504 running on a CMSIS-DAP device, using EDBG protocol */
--- trunk/libavrdude.h (revision 1467)
+++ trunk/libavrdude.h (revision 1468)
@@ -629,7 +629,7 @@
629629 int ppictrl;
630630 int baudrate;
631631 int usbvid;
632- LISTID usbpid;
632+ std::vector<int> usbpid;
633633 char usbdev[PGM_USBSTRINGLEN], usbsn[PGM_USBSTRINGLEN];
634634 char usbvendor[PGM_USBSTRINGLEN], usbproduct[PGM_USBSTRINGLEN];
635635 double bitclock; /* JTAG ICE clock period in microseconds */
@@ -697,7 +697,6 @@
697697
698698 PROGRAMMER *pgm_new();
699699 PROGRAMMER *pgm_dup(const PROGRAMMER *src);
700-void pgm_free(PROGRAMMER * const p);
701700
702701 void programmer_display(PROGRAMMER * pgm, const char * p);
703702
--- trunk/pgm.cpp (revision 1467)
+++ trunk/pgm.cpp (revision 1468)
@@ -108,7 +108,6 @@
108108 pgm->cookie = 0;
109109 pgm->flag = 0;
110110
111- pgm->usbpid = lcreat(NULL, 0);
112111 pgm->desc[0] = 0;
113112 pgm->type[0] = 0;
114113 pgm->config_file[0] = 0;
@@ -171,44 +170,18 @@
171170 return pgm;
172171 }
173172
174-void pgm_free(PROGRAMMER * const p)
175-{
176- ldestroy_cb(p->usbpid, free);
177- p->usbpid = NULL;
178- /* this is done by pgm_teardown, but usually cookie is not set to NULL */
179- /* if (p->cookie !=NULL) {
180- free(p->cookie);
181- p->cookie = NULL;
182- }*/
183-}
184-
185173 PROGRAMMER *pgm_dup(const PROGRAMMER *src)
186174 {
187- LNODEID ln;
188-
189175 PROGRAMMER *pgm = new PROGRAMMER(*src);
190- if (pgm == NULL) {
176+ if(pgm == NULL)
177+ {
191178 avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n",
192179 progname);
193180 return NULL;
194181 }
195182
196- //memcpy(pgm, src, sizeof(*pgm));
197-
198183 pgm->id.clear();
199- pgm->usbpid = lcreat(NULL, 0);
200184
201- for (ln = lfirst(src->usbpid); ln; ln = lnext(ln)) {
202- int *ip = static_cast<int*>(malloc(sizeof(int)));
203- if (ip == NULL) {
204- avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n",
205- progname);
206- exit(1);
207- }
208- *ip = *(int *) ldata(ln);
209- ladd(pgm->usbpid, ip);
210- }
211-
212185 return pgm;
213186 }
214187
--- trunk/pgm_type.cpp (revision 1467)
+++ trunk/pgm_type.cpp (revision 1468)
@@ -152,7 +152,6 @@
152152 PROGRAMMER *p = &(*it);
153153 if(p == data_ptr)
154154 {
155- pgm_free(p);
156155 programmers.erase(it);
157156 return;
158157 }
--- trunk/usbasp.cpp (revision 1467)
+++ trunk/usbasp.cpp (revision 1468)
@@ -468,14 +468,18 @@
468468 progname, port);
469469
470470 /* usb_init will be done in usbOpenDevice */
471- LNODEID usbpid = lfirst(pgm->usbpid);
472471 int pid, vid;
473- if (usbpid) {
474- pid = *(int *)(ldata(usbpid));
475- if (lnext(usbpid))
472+ if(pgm->usbpid.size())
473+ {
474+ pid = pgm->usbpid[0];
475+ if(pgm->usbpid.size() > 1)
476+ {
476477 avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
477478 progname, pid);
478- } else {
479+ }
480+ }
481+ else
482+ {
479483 pid = USBASP_SHARED_PID;
480484 }
481485 vid = pgm->usbvid? pgm->usbvid: USBASP_SHARED_VID;
--- trunk/usbtiny.cpp (revision 1467)
+++ trunk/usbtiny.cpp (revision 1468)
@@ -333,13 +333,17 @@
333333 else
334334 vid = USBTINY_VENDOR_DEFAULT;
335335
336- LNODEID usbpid = lfirst(pgm->usbpid);
337- if (usbpid) {
338- pid = *(int *)(ldata(usbpid));
339- if (lnext(usbpid))
336+ if(pgm->usbpid.size())
337+ {
338+ pid = pgm->usbpid[0];
339+ if(pgm->usbpid.size() > 1)
340+ {
340341 avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
341342 progname, pid);
342- } else {
343+ }
344+ }
345+ else
346+ {
343347 pid = USBTINY_PRODUCT_DEFAULT;
344348 }
345349
Show on old repository browser