From 28f4807dd3f0c1e9ddaf517122c97fe84e6ff1b8 Mon Sep 17 00:00:00 2001 From: Matt Schulte Date: Wed, 7 Feb 2024 16:24:26 -0800 Subject: [PATCH] fastboot: Remove '\n' from interface name on linux If the device provides an interface string, we should remove the newline from the read file that is added from by the linux kernel. Bug: 324320178 Test: Ran the same command with my local changes vs not ``` bash$ ./fastboot devices -l 5f42ad5ad259c90cf14ea222791b6aaa fastboot usb:7-3 bash$ fastboot devices -l 5f42ad5ad259c90cf14ea222791b6aaa fastboot usb:7-3 ``` Change-Id: Ida3316fdba8e35f0c66784f83455a4d82e90ba1c --- fastboot/usb_linux.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastboot/usb_linux.cpp b/fastboot/usb_linux.cpp index b7fd5ed33..72e326a78 100644 --- a/fastboot/usb_linux.cpp +++ b/fastboot/usb_linux.cpp @@ -269,6 +269,9 @@ static int filter_usb_device(char* sysfs_name, auto path = android::base::StringPrintf("/sys/bus/usb/devices/%s/%s:1.%d/interface", sysfs_name, sysfs_name, ifc->bInterfaceNumber); if (android::base::ReadFileToString(path, &interface)) { + if (!interface.empty() && interface.back() == '\n') { + interface.pop_back(); + } snprintf(info.interface, sizeof(info.interface), "%s", interface.c_str()); }