From 8daa93b55c3d05adb951f1f494eaf29ba5caec38 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 20 Aug 2017 16:19:24 +0200 Subject: ... --- car/pb_stream.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'car') diff --git a/car/pb_stream.cpp b/car/pb_stream.cpp index f5c3dc5..41100ed 100644 --- a/car/pb_stream.cpp +++ b/car/pb_stream.cpp @@ -8,13 +8,10 @@ bool os_read(pb_istream_t *stream, uint8_t *buf, size_t count) { Stream *s = static_cast(stream->state); - while (count > 0) { - if (s->available() > 0) { - size_t readCount = s->readBytes((char *)buf, count); - count -= readCount; - } + while (s->available() > 0 && count > 0) { + count -= s->readBytes((char *)buf, count); } - return true; + return count == 0; } -- cgit v1.2.3