From 4e29924d3d5ef1e9e13df46bf249f91593c73946 Mon Sep 17 00:00:00 2001 From: RD Babiera Date: Thu, 20 Apr 2023 17:33:00 +0000 Subject: [PATCH] usb: Fix HAL build warnings related to DisplayPort Adds proper error handling go-to points to remove warnings arising from uninitialized variables, and removes unused queryDisplayPortStatus() method. Test: manual test on device, verify compiler warnings Bug: 278951278 Change-Id: I54f7b710a0805b32c894d741e473d64814200134 --- usb/usb/Usb.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp index 04eabd54..19454049 100644 --- a/usb/usb/Usb.cpp +++ b/usb/usb/Usb.cpp @@ -764,11 +764,6 @@ done: return Status::ERROR; } -Status queryDisplayPortStatus(std::vector *currentPortStatus) { - - return Status::SUCCESS; -} - void queryVersionHelper(android::hardware::usb::Usb *usb, std::vector *currentPortStatus) { Status status; @@ -1185,7 +1180,7 @@ void *displayPortPollWork(void *param) { if (usb->getDisplayPortUsbPathHelper(&displayPortUsbPath) == Status::ERROR) { ALOGE("usbdp: could not locate usb displayport directory"); - goto error; + goto usb_path_error; } ALOGI("usbdp: displayport usb path located at %s", displayPortUsbPath.c_str()); hpdPath = displayPortUsbPath + "hpd"; @@ -1196,21 +1191,21 @@ void *displayPortPollWork(void *param) { epoll_fd = epoll_create(64); if (epoll_fd == -1) { ALOGE("usbdp: epoll_create failed; errno=%d", errno); - goto error; + goto epoll_fd_error; } if ((hpd_fd = displayPortPollOpenFileHelper(hpdPath.c_str(), file_flags)) == -1){ - goto error; + goto hpd_fd_error; } if ((pin_fd = displayPortPollOpenFileHelper(pinAssignmentPath.c_str(), file_flags)) == -1){ - goto error; + goto pin_fd_error; } if ((orientation_fd = displayPortPollOpenFileHelper(orientationPath.c_str(), file_flags)) == -1){ - goto error; + goto orientation_fd_error; } if ((link_fd = displayPortPollOpenFileHelper(linkPath.c_str(), file_flags)) == -1){ - goto error; + goto link_fd_error; } // Set epoll_event events and flags @@ -1294,15 +1289,19 @@ void *displayPortPollWork(void *param) { } error: - ALOGI("usbdp: Exiting worker thread"); - close(hpd_fd); - close(pin_fd); - close(orientation_fd); close(link_fd); - - if (epoll_fd >= 0) - epoll_ctl(epoll_fd, EPOLL_CTL_DEL, usb->mDisplayPortShutdown, &ev_eventfd); - close(epoll_fd); +link_fd_error: + close(orientation_fd); +orientation_fd_error: + close(pin_fd); +pin_fd_error: + close(hpd_fd); +hpd_fd_error: + epoll_ctl(epoll_fd, EPOLL_CTL_DEL, usb->mDisplayPortShutdown, &ev_eventfd); + close(epoll_fd); +epoll_fd_error: +usb_path_error: + ALOGI("usbdp: Exiting worker thread"); return NULL; }