Skip to content

Commit

Permalink
Clean up endpoint operations result checking
Browse files Browse the repository at this point in the history
No functional changes.
  • Loading branch information
xairy committed Aug 24, 2024
1 parent c6454ce commit 4d3b90e
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ void *ep_loop_write(void *arg) {
ep.bEndpointAddress, transfer_type.c_str(), dir.c_str());
continue;
}
else if (rv < 0) {
if (rv < 0) {
perror("usb_raw_ep_write()");
exit(EXIT_FAILURE);
}
else {
printf("EP%x(%s_%s): wrote %d bytes to host\n", ep.bEndpointAddress,
transfer_type.c_str(), dir.c_str(), rv);
}
printf("EP%x(%s_%s): wrote %d bytes to host\n", ep.bEndpointAddress,
transfer_type.c_str(), dir.c_str(), rv);
}
else {
int length = io.inner.length;
Expand Down Expand Up @@ -249,25 +247,23 @@ void *ep_loop_read(void *arg) {
ep.bEndpointAddress, transfer_type.c_str(), dir.c_str());
break;
}
else if (rv < 0) {
if (rv < 0) {
perror("usb_raw_ep_read()");
exit(EXIT_FAILURE);
}
else {
printf("EP%x(%s_%s): read %d bytes from host\n", ep.bEndpointAddress,
transfer_type.c_str(), dir.c_str(), rv);
io.inner.length = rv;
printf("EP%x(%s_%s): read %d bytes from host\n", ep.bEndpointAddress,
transfer_type.c_str(), dir.c_str(), rv);
io.inner.length = rv;

if (injection_enabled)
injection(io, ep, transfer_type);
if (injection_enabled)
injection(io, ep, transfer_type);

data_mutex->lock();
data_queue->push_back(io);
data_mutex->unlock();
if (verbose_level)
printf("EP%x(%s_%s): enqueued %d bytes to queue\n", ep.bEndpointAddress,
transfer_type.c_str(), dir.c_str(), rv);
}
data_mutex->lock();
data_queue->push_back(io);
data_mutex->unlock();
if (verbose_level)
printf("EP%x(%s_%s): enqueued %d bytes to queue\n", ep.bEndpointAddress,
transfer_type.c_str(), dir.c_str(), rv);
}
}

Expand Down

0 comments on commit 4d3b90e

Please sign in to comment.