From c87e0d5d5f3bfb476e56cb8da7cae7a8ff497a7a Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Tue, 29 Apr 2025 00:00:42 -0500 Subject: [PATCH] Fix --auto new and --auto latest on MacOS. (redo) Git is being dumb about https://github.com/tio/tio/commit/67c071633dc6d659fae1e529a85f5990531e1669 This PR is identical to that one and will supercede it. 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. --- src/tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tty.c b/src/tty.c index 6de4af7..c5e6876 100644 --- a/src/tty.c +++ b/src/tty.c @@ -1938,7 +1938,7 @@ char *getDeviceLocation(io_object_t device) // for __APPLE__ GList *tty_search_for_serial_devices(void) { - GList *device_list = NULL; + search_reset(); io_iterator_t iter = IO_OBJECT_NULL; CFMutableDictionaryRef matchingDict = NULL; listing_device_name_length_max = 0;