summaryrefslogtreecommitdiff
path: root/osi
diff options
context:
space:
mode:
authorAndre Eisenbach <eisenbach@google.com>2015-11-20 14:07:24 -0800
committerAndre Eisenbach <eisenbach@google.com>2015-12-22 19:11:50 -0800
commitb9757ee3c9f1bb4d521624606db5b2e7ba722eeb (patch)
tree2a37292fcd52de3e27ea9de65e3608e7abb161fc /osi
parent48df46b8398cf224a5209002cce3d534c4480d99 (diff)
downloadandroid-system-bt-b9757ee3c9f1bb4d521624606db5b2e7ba722eeb.tar.gz
android-system-bt-b9757ee3c9f1bb4d521624606db5b2e7ba722eeb.tar.xz
Remove "block" parameter from eager_reader_read()
Setting this parameter to true did not work and did not behave as expected. The functionality provided by this parameter is also not necessary, thus removing code. Change-Id: I29e60da4adf1d1fc84d8ec9a590de89e94bb7900
Diffstat (limited to 'osi')
-rw-r--r--osi/include/eager_reader.h5
-rw-r--r--osi/src/eager_reader.c7
-rw-r--r--osi/test/eager_reader_test.cpp4
3 files changed, 7 insertions, 9 deletions
diff --git a/osi/include/eager_reader.h b/osi/include/eager_reader.h
index 49fe948..c87995d 100644
--- a/osi/include/eager_reader.h
+++ b/osi/include/eager_reader.h
@@ -56,12 +56,11 @@ void eager_reader_register(eager_reader_t *reader, reactor_t *reactor, eager_rea
// function is idempotent.
void eager_reader_unregister(eager_reader_t *reader);
-// Reads up to |max_size| bytes into |buffer|. If |block| is true, blocks until
-// |max_size| bytes are read. Otherwise only reads from currently available bytes.
+// Reads up to |max_size| bytes into |buffer| from currently available bytes.
// NOT SAFE FOR READING FROM MULTIPLE THREADS
// but you should probably only be reading from one thread anyway,
// otherwise the byte stream probably doesn't make sense.
-size_t eager_reader_read(eager_reader_t *reader, uint8_t *buffer, size_t max_size, bool block);
+size_t eager_reader_read(eager_reader_t *reader, uint8_t *buffer, size_t max_size);
// Returns the inbound read thread for a given |reader| or NULL if the thread
// is not running.
diff --git a/osi/src/eager_reader.c b/osi/src/eager_reader.c
index 6b07561..29a7cec 100644
--- a/osi/src/eager_reader.c
+++ b/osi/src/eager_reader.c
@@ -165,13 +165,12 @@ void eager_reader_unregister(eager_reader_t *reader) {
}
// SEE HEADER FOR THREAD SAFETY NOTE
-size_t eager_reader_read(eager_reader_t *reader, uint8_t *buffer, size_t max_size, bool block) {
+size_t eager_reader_read(eager_reader_t *reader, uint8_t *buffer, size_t max_size) {
assert(reader != NULL);
assert(buffer != NULL);
- // If the caller wants nonblocking behavior, poll to see if we have
- // any bytes available before reading.
- if (!block && !has_byte(reader))
+ // Poll to see if we have any bytes available before reading.
+ if (!has_byte(reader))
return 0;
// Find out how many bytes we have available in our various buffers.
diff --git a/osi/test/eager_reader_test.cpp b/osi/test/eager_reader_test.cpp
index 6848cca..7156d56 100644
--- a/osi/test/eager_reader_test.cpp
+++ b/osi/test/eager_reader_test.cpp
@@ -90,7 +90,7 @@ static void expect_data(eager_reader_t *reader, void *context) {
for (int i = 0; i < length; i++) {
uint8_t byte;
- EXPECT_EQ((size_t)1, eager_reader_read(reader, &byte, 1, true));
+ EXPECT_EQ((size_t)1, eager_reader_read(reader, &byte, 1));
EXPECT_EQ(data[i], byte);
}
@@ -104,7 +104,7 @@ static void expect_data_multibyte(eager_reader_t *reader, void *context) {
for (size_t i = 0; i < length;) {
uint8_t buffer[28];
size_t bytes_to_read = (length - i) > 28 ? 28 : (length - i);
- size_t bytes_read = eager_reader_read(reader, buffer, bytes_to_read, false);
+ size_t bytes_read = eager_reader_read(reader, buffer, bytes_to_read);
EXPECT_LE(bytes_read, bytes_to_read);
for (size_t j = 0; j < bytes_read && i < length; j++, i++) {
EXPECT_EQ(data[i], buffer[j]);