Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1f6e1b1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "H4: Return early if bytes_read is 0" am: 870224c2

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1828095

Change-Id: Ib4a2042b384a32748fc8bf1eb01b4be9728feafa
parents 240b6cc7 870224c2
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -97,7 +97,15 @@ void H4Protocol::OnDataReady(int fd) {
        const size_t max_plen = 64*1024;
        hidl_vec<uint8_t> tpkt;
        tpkt.resize(max_plen);
        size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, tpkt.data(), max_plen));
        ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, tpkt.data(), max_plen));
        if (bytes_read == 0) {
            ALOGI("No bytes read");
            return;
        }
        if (bytes_read < 0) {
            ALOGW("error reading from UART (%s)", strerror(errno));
            return;
        }
        hci_packet_type_ = static_cast<HciPacketType>(tpkt.data()[0]);
        hci_packetizer_.CbHciPacket(tpkt.data()+1, bytes_read-1);
    }