@@ -35,35 +35,35 @@ namespace android::gui {
3535namespace {
3636
3737template <typename T>
38- static void readAligned (const void *& buffer, size_t & size, T& value) {
38+ void readAligned (const void *& buffer, size_t & size, T& value) {
3939 size -= FlattenableUtils::align<alignof (T)>(buffer);
4040 FlattenableUtils::read (buffer, size, value);
4141}
4242
4343template <typename T>
44- static void writeAligned (void *& buffer, size_t & size, T value) {
44+ void writeAligned (void *& buffer, size_t & size, T value) {
4545 size -= FlattenableUtils::align<alignof (T)>(buffer);
4646 FlattenableUtils::write (buffer, size, value);
4747}
4848
4949template <typename T>
50- static void addAligned (size_t & size, T /* value */ ) {
50+ void addAligned (size_t & size, T /* value */ ) {
5151 size = FlattenableUtils::align<sizeof (T)>(size);
5252 size += sizeof (T);
5353}
5454
5555template <typename T>
56- static inline constexpr uint32_t low32 (const T n) {
56+ inline constexpr uint32_t low32 (const T n) {
5757 return static_cast <uint32_t >(static_cast <uint64_t >(n));
5858}
5959
6060template <typename T>
61- static inline constexpr uint32_t high32 (const T n) {
61+ inline constexpr uint32_t high32 (const T n) {
6262 return static_cast <uint32_t >(static_cast <uint64_t >(n) >> 32 );
6363}
6464
6565template <typename T>
66- static inline constexpr T to64 (const uint32_t lo, const uint32_t hi) {
66+ inline constexpr T to64 (const uint32_t lo, const uint32_t hi) {
6767 return static_cast <T>(static_cast <uint64_t >(hi) << 32 | lo);
6868}
6969
@@ -139,19 +139,18 @@ status_t BufferReleaseChannel::ConsumerEndpoint::readReleaseFence(
139139 std::lock_guard lock{mMutex };
140140 Message message;
141141 mFlattenedBuffer .resize (message.getFlattenedSize ());
142- std::array<uint8_t , CMSG_SPACE (sizeof (int ))> controlMessageBuffer;
142+ std::array<uint8_t , CMSG_SPACE (sizeof (int ))> controlMessageBuffer{} ;
143143
144144 iovec iov{
145145 .iov_base = mFlattenedBuffer .data (),
146146 .iov_len = mFlattenedBuffer .size (),
147147 };
148148
149- msghdr msg{
150- .msg_iov = &iov,
151- .msg_iovlen = 1 ,
152- .msg_control = controlMessageBuffer.data (),
153- .msg_controllen = controlMessageBuffer.size (),
154- };
149+ msghdr msg{};
150+ msg.msg_iov = &iov;
151+ msg.msg_iovlen = 1 ;
152+ msg.msg_control = controlMessageBuffer.data ();
153+ msg.msg_controllen = controlMessageBuffer.size ();
155154
156155 ssize_t result;
157156 do {
@@ -161,7 +160,7 @@ status_t BufferReleaseChannel::ConsumerEndpoint::readReleaseFence(
161160 if (errno == EWOULDBLOCK || errno == EAGAIN) {
162161 return WOULD_BLOCK;
163162 }
164- ALOGE (" Error reading release fence from socket: error %#x (%s)" , errno, strerror (errno));
163+ ALOGE (" Error reading release fence from socket: error %d (%s)" , errno, strerror (errno));
165164 return UNKNOWN_ERROR;
166165 }
167166
@@ -200,9 +199,9 @@ status_t BufferReleaseChannel::ConsumerEndpoint::readReleaseFence(
200199 return OK;
201200}
202201
203- int BufferReleaseChannel::ProducerEndpoint::writeReleaseFence (const ReleaseCallbackId& callbackId,
204- const sp<Fence>& fence,
205- uint32_t maxAcquiredBufferCount) {
202+ status_t BufferReleaseChannel::ProducerEndpoint::writeReleaseFence (
203+ const ReleaseCallbackId& callbackId, const sp<Fence>& fence,
204+ uint32_t maxAcquiredBufferCount) {
206205 Message message{callbackId, fence ? fence : Fence::NO_FENCE, maxAcquiredBufferCount};
207206 mFlattenedBuffer .resize (message.getFlattenedSize ());
208207 int flattenedFd;
@@ -213,25 +212,22 @@ int BufferReleaseChannel::ProducerEndpoint::writeReleaseFence(const ReleaseCallb
213212 size_t flattenedBufferSize = mFlattenedBuffer .size ();
214213 int * flattenedFdPtr = &flattenedFd;
215214 size_t flattenedFdCount = 1 ;
216- if (status_t err = message.flatten (flattenedBufferPtr, flattenedBufferSize, flattenedFdPtr,
217- flattenedFdCount);
218- err != OK) {
219- ALOGE (" Failed to flatten BufferReleaseChannel message." );
220- return err;
215+ if (status_t status = message.flatten (flattenedBufferPtr, flattenedBufferSize,
216+ flattenedFdPtr, flattenedFdCount);
217+ status != OK) {
218+ return status;
221219 }
222220 }
223221
224- iovec iov{
225- .iov_base = mFlattenedBuffer .data (),
226- .iov_len = mFlattenedBuffer .size (),
227- };
222+ iovec iov{};
223+ iov.iov_base = mFlattenedBuffer .data ();
224+ iov.iov_len = mFlattenedBuffer .size ();
228225
229- msghdr msg{
230- .msg_iov = &iov,
231- .msg_iovlen = 1 ,
232- };
226+ msghdr msg{};
227+ msg.msg_iov = &iov;
228+ msg.msg_iovlen = 1 ;
233229
234- std::array<uint8_t , CMSG_SPACE (sizeof (int ))> controlMessageBuffer;
230+ std::array<uint8_t , CMSG_SPACE (sizeof (int ))> controlMessageBuffer{} ;
235231 if (fence && fence->isValid ()) {
236232 msg.msg_control = controlMessageBuffer.data ();
237233 msg.msg_controllen = controlMessageBuffer.size ();
@@ -248,7 +244,6 @@ int BufferReleaseChannel::ProducerEndpoint::writeReleaseFence(const ReleaseCallb
248244 result = sendmsg (mFd , &msg, 0 );
249245 } while (result == -1 && errno == EINTR);
250246 if (result == -1 ) {
251- ALOGD (" Error writing release fence to socket: error %#x (%s)" , errno, strerror (errno));
252247 return -errno;
253248 }
254249
0 commit comments