Commit 7bec6951 authored by Wez's avatar Wez Committed by Commit Bot

Fix DataPipe(capacity) constructor not to double-allocate.

The DataPipe(capacity) constructor was previously creating a DataPipe
on the stack, using the DataPipe(options) constructor, but then not
using it, and instead manually creating the pipe handles to return to
the caller.

Remove the wasted work, and clean up some ALLOW_UNUSED_LOCAL() that are
no longer required, since DCHECKs in DataPipe() constructors were
replaced with CHECKs.

Bug: 892297, 890468
Change-Id: Id09cd7878faa9b796858169125ff6f05d19dc5f8
Reviewed-on: https://chromium-review.googlesource.com/c/1266602Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597623}
parent ad413819
...@@ -149,7 +149,6 @@ class DataPipe { ...@@ -149,7 +149,6 @@ class DataPipe {
inline DataPipe::DataPipe() { inline DataPipe::DataPipe() {
MojoResult result = MojoResult result =
CreateDataPipe(nullptr, &producer_handle, &consumer_handle); CreateDataPipe(nullptr, &producer_handle, &consumer_handle);
ALLOW_UNUSED_LOCAL(result);
CHECK_EQ(MOJO_RESULT_OK, result); CHECK_EQ(MOJO_RESULT_OK, result);
} }
...@@ -159,17 +158,14 @@ inline DataPipe::DataPipe(uint32_t capacity_num_bytes) { ...@@ -159,17 +158,14 @@ inline DataPipe::DataPipe(uint32_t capacity_num_bytes) {
options.flags = MOJO_CREATE_DATA_PIPE_FLAG_NONE; options.flags = MOJO_CREATE_DATA_PIPE_FLAG_NONE;
options.element_num_bytes = 1; options.element_num_bytes = 1;
options.capacity_num_bytes = capacity_num_bytes; options.capacity_num_bytes = capacity_num_bytes;
mojo::DataPipe data_pipe(options);
MojoResult result = MojoResult result =
CreateDataPipe(&options, &producer_handle, &consumer_handle); CreateDataPipe(&options, &producer_handle, &consumer_handle);
ALLOW_UNUSED_LOCAL(result);
CHECK_EQ(MOJO_RESULT_OK, result); CHECK_EQ(MOJO_RESULT_OK, result);
} }
inline DataPipe::DataPipe(const MojoCreateDataPipeOptions& options) { inline DataPipe::DataPipe(const MojoCreateDataPipeOptions& options) {
MojoResult result = MojoResult result =
CreateDataPipe(&options, &producer_handle, &consumer_handle); CreateDataPipe(&options, &producer_handle, &consumer_handle);
ALLOW_UNUSED_LOCAL(result);
CHECK_EQ(MOJO_RESULT_OK, result); CHECK_EQ(MOJO_RESULT_OK, result);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment