Commit 8d9eff3b authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

x11: clang-tidy: Modernize x11_shm_image_pool_base.cc

Tricium has started complaining about clang-tidy checks in
x11_shm_image_pool_base.cc at https://crrev.com/a/1747274. This patch
addresses the issues reported by it.

Bug: None
Change-Id: I9c117bdddd767e1b14b0b2df68ad97e9037b12a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013365
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733835}
parent 36e05e7f
...@@ -194,16 +194,16 @@ bool XShmImagePoolBase::Resize(const gfx::Size& pixel_size) { ...@@ -194,16 +194,16 @@ bool XShmImagePoolBase::Resize(const gfx::Size& pixel_size) {
if (state.shminfo_.shmid < 0) if (state.shminfo_.shmid < 0)
return false; return false;
state.shminfo_.shmaddr = state.shminfo_.shmaddr =
reinterpret_cast<char*>(shmat(state.shminfo_.shmid, 0, 0)); reinterpret_cast<char*>(shmat(state.shminfo_.shmid, nullptr, 0));
if (state.shminfo_.shmaddr == reinterpret_cast<char*>(-1)) { if (state.shminfo_.shmaddr == reinterpret_cast<char*>(-1)) {
shmctl(state.shminfo_.shmid, IPC_RMID, 0); shmctl(state.shminfo_.shmid, IPC_RMID, nullptr);
return false; return false;
} }
#if defined(OS_LINUX) #if defined(OS_LINUX)
// On Linux, a shmid can still be attached after IPC_RMID if otherwise // On Linux, a shmid can still be attached after IPC_RMID if otherwise
// kept alive. Detach before XShmAttach to prevent a memory leak in case // kept alive. Detach before XShmAttach to prevent a memory leak in case
// the process dies. // the process dies.
shmctl(state.shminfo_.shmid, IPC_RMID, 0); shmctl(state.shminfo_.shmid, IPC_RMID, nullptr);
#endif #endif
DCHECK(!state.shmem_attached_to_server_); DCHECK(!state.shmem_attached_to_server_);
if (!XShmAttach(display_, &state.shminfo_)) if (!XShmAttach(display_, &state.shminfo_))
...@@ -214,7 +214,7 @@ bool XShmImagePoolBase::Resize(const gfx::Size& pixel_size) { ...@@ -214,7 +214,7 @@ bool XShmImagePoolBase::Resize(const gfx::Size& pixel_size) {
// forced to do IPC_RMID after the server has attached to the segment. // forced to do IPC_RMID after the server has attached to the segment.
// XShmAttach is asynchronous, so we must also sync. // XShmAttach is asynchronous, so we must also sync.
XSync(display_, x11::False); XSync(display_, x11::False);
shmctl(shminfo_.shmid, IPC_RMID, 0); shmctl(shminfo_.shmid, IPC_RMID, nullptr);
#endif #endif
// If this class ever needs to use XShmGetImage(), this needs to be // If this class ever needs to use XShmGetImage(), this needs to be
// changed to read-write. // changed to read-write.
...@@ -222,8 +222,7 @@ bool XShmImagePoolBase::Resize(const gfx::Size& pixel_size) { ...@@ -222,8 +222,7 @@ bool XShmImagePoolBase::Resize(const gfx::Size& pixel_size) {
} }
} }
for (std::size_t i = 0; i < frame_states_.size(); ++i) { for (FrameState& state : frame_states_) {
FrameState& state = frame_states_[i];
state.image->data = state.shminfo_.shmaddr; state.image->data = state.shminfo_.shmaddr;
SkImageInfo image_info = SkImageInfo image_info =
SkImageInfo::Make(state.image->width, state.image->height, SkImageInfo::Make(state.image->width, state.image->height,
......
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