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

Commit 870224c2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "H4: Return early if bytes_read is 0"

parents c5e497c1 113ea287
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);
    }