Fix --auto new and --auto latest on MacOS.

'device_list' was both a global (eww!) and a local inside
tty_search_for_serial_devices(). The local got set and
returned, so it looked sane, but the caller used the global
instead of the return value of the function it had just
called, meaning (global) device_list was NULL while
(ignored, local) device_list held a perfectly lovely
linked list.

Tested:
tio --auto new waits for a new device to appare and connects
tio --latest will connect to the most recently attached device
  which, in most worlds, is the most recently enumerated USB
  device, conveniently skipping all the bluetooth nonsense.
  If the lone USB device is disconnected, it then connects to
  one of those, meaning you really do have to restart tio.
This commit is contained in:
Robert Lipe 2025-04-28 03:47:23 -05:00
parent 22dd954550
commit 67c071633d

View file

@ -1938,7 +1938,7 @@ char *getDeviceLocation(io_object_t device)
// for __APPLE__ // for __APPLE__
GList *tty_search_for_serial_devices(void) GList *tty_search_for_serial_devices(void)
{ {
GList *device_list = NULL; search_reset();
io_iterator_t iter = IO_OBJECT_NULL; io_iterator_t iter = IO_OBJECT_NULL;
CFMutableDictionaryRef matchingDict = NULL; CFMutableDictionaryRef matchingDict = NULL;
listing_device_name_length_max = 0; listing_device_name_length_max = 0;