[sysmem] If Close() was called after allocation don't log error
This is a normal way for the buffer collection to close, so it should be
logged as info.
Test: only a logging change
Change-Id: I04188d609610c837625c15bc6ca1c62cf1eb839c
diff --git a/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.cc b/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.cc
index ab7255c..71c6695 100644
--- a/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.cc
+++ b/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.cc
@@ -269,10 +269,12 @@
}
void LogicalBufferCollection::Fail(const char* format, ...) {
- va_list args;
- va_start(args, format);
- vLog(true, "LogicalBufferCollection", "fail", format, args);
- va_end(args);
+ if (format) {
+ va_list args;
+ va_start(args, format);
+ vLog(true, "LogicalBufferCollection", "fail", format, args);
+ va_end(args);
+ }
// Close all the associated channels. We do this by swapping into local
// collections and clearing those, since deleting the items in the
@@ -326,8 +328,9 @@
// The LogicalBufferCollection should be failed because there are no clients left, despite only
// getting here if all of the clients did a clean Close().
if (is_allocate_attempted_) {
- // A case could be made for making this a silent failure.
- Fail("All clients called Close(), but now zero clients remain (after allocation).");
+ // Only log as info because this is a normal way to destroy the buffer collection.
+ LogInfo("All clients called Close(), but now zero clients remain (after allocation).");
+ Fail(nullptr);
} else {
Fail("All clients called Close(), but now zero clients remain (before allocation).");
}
diff --git a/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.h b/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.h
index dd348eb..a40ce9d 100644
--- a/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.h
+++ b/zircon/system/dev/sysmem/sysmem/logical_buffer_collection.h
@@ -74,6 +74,8 @@
private:
LogicalBufferCollection(Device* parent_device);
+ // If |format| is nonnull, will log an error. This also cleans out a lot of
+ // state that's unnecessary after a failure.
void Fail(const char* format, ...);
static void LogInfo(const char* format, ...);