aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-08-20 16:19:24 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-08-20 16:19:24 +0200
commit8daa93b55c3d05adb951f1f494eaf29ba5caec38 (patch)
treed7029993c18713bfe16fd5067ed9614e11f02d99
parentfb6b2ea23f8ca073995ad86429924cdd0af38c46 (diff)
...
-rw-r--r--car/pb_stream.cpp9
1 files changed, 3 insertions, 6 deletions
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 *>(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;
}