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: 297286558
Change-Id: I54f7b710a0805b32c894d741e473d64814200134
(cherry picked from commit 4e29924d3d5ef1e9e13df46bf249f91593c73946)
Signed-off-by: RD Babiera <rdbabiera@google.com>
This commit is contained in:
RD Babiera 2023-04-20 17:33:00 +00:00
parent 94dac0240c
commit 667ff0cf59

View file

@ -764,11 +764,6 @@ done:
return Status::ERROR; return Status::ERROR;
} }
Status queryDisplayPortStatus(std::vector<PortStatus> *currentPortStatus) {
return Status::SUCCESS;
}
void queryVersionHelper(android::hardware::usb::Usb *usb, void queryVersionHelper(android::hardware::usb::Usb *usb,
std::vector<PortStatus> *currentPortStatus) { std::vector<PortStatus> *currentPortStatus) {
Status status; Status status;
@ -1185,7 +1180,7 @@ void *displayPortPollWork(void *param) {
if (usb->getDisplayPortUsbPathHelper(&displayPortUsbPath) == Status::ERROR) { if (usb->getDisplayPortUsbPathHelper(&displayPortUsbPath) == Status::ERROR) {
ALOGE("usbdp: could not locate usb displayport directory"); 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()); ALOGI("usbdp: displayport usb path located at %s", displayPortUsbPath.c_str());
hpdPath = displayPortUsbPath + "hpd"; hpdPath = displayPortUsbPath + "hpd";
@ -1196,21 +1191,21 @@ void *displayPortPollWork(void *param) {
epoll_fd = epoll_create(64); epoll_fd = epoll_create(64);
if (epoll_fd == -1) { if (epoll_fd == -1) {
ALOGE("usbdp: epoll_create failed; errno=%d", errno); ALOGE("usbdp: epoll_create failed; errno=%d", errno);
goto error; goto epoll_fd_error;
} }
if ((hpd_fd = displayPortPollOpenFileHelper(hpdPath.c_str(), file_flags)) == -1){ 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){ 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)) if ((orientation_fd = displayPortPollOpenFileHelper(orientationPath.c_str(), file_flags))
== -1){ == -1){
goto error; goto orientation_fd_error;
} }
if ((link_fd = displayPortPollOpenFileHelper(linkPath.c_str(), file_flags)) == -1){ if ((link_fd = displayPortPollOpenFileHelper(linkPath.c_str(), file_flags)) == -1){
goto error; goto link_fd_error;
} }
// Set epoll_event events and flags // Set epoll_event events and flags
@ -1294,15 +1289,19 @@ void *displayPortPollWork(void *param) {
} }
error: error:
ALOGI("usbdp: Exiting worker thread");
close(hpd_fd);
close(pin_fd);
close(orientation_fd);
close(link_fd); close(link_fd);
link_fd_error:
if (epoll_fd >= 0) 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); epoll_ctl(epoll_fd, EPOLL_CTL_DEL, usb->mDisplayPortShutdown, &ev_eventfd);
close(epoll_fd); close(epoll_fd);
epoll_fd_error:
usb_path_error:
ALOGI("usbdp: Exiting worker thread");
return NULL; return NULL;
} }