From ff88a8279aef2f5fa9d03b21d6a001fbb14bbb99 Mon Sep 17 00:00:00 2001 From: Kalyan Kondapally Date: Sat, 4 Mar 2017 17:11:54 -0800 Subject: [PATCH] Try closing fd only when it's > 0. Jira: None. Test: No regressions with test apps. Signed-off-by: Kalyan Kondapally --- common/compositor/gl/nativeglresource.cpp | 5 +++-- public/scopedfd.h | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/compositor/gl/nativeglresource.cpp b/common/compositor/gl/nativeglresource.cpp index 440fa37..17d5ffb 100644 --- a/common/compositor/gl/nativeglresource.cpp +++ b/common/compositor/gl/nativeglresource.cpp @@ -57,8 +57,9 @@ NativeGLResource::~NativeGLResource() { void NativeGLResource::Reset() { GLuint texture_id = 0; - for (uint32_t i = 0; i < layer_textures_.size(); i++) { - texture_id = layer_textures_[i]; + size_t size = layer_textures_.size(); + for (size_t i = 0; i < size; i++) { + texture_id = layer_textures_.at(i); glDeleteTextures(1, &texture_id); } } diff --git a/public/scopedfd.h b/public/scopedfd.h index 3a89306..5d46f50 100644 --- a/public/scopedfd.h +++ b/public/scopedfd.h @@ -37,7 +37,7 @@ class ScopedFd { } ~ScopedFd() { - if (fd_ >= 0) + if (fd_ > 0) close(fd_); } @@ -48,14 +48,14 @@ class ScopedFd { } int Reset(int fd) { - if (fd_ >= 0) + if (fd_ > 0) close(fd_); fd_ = fd; return fd_; } void Close() { - if (fd_ >= 0) + if (fd_ > 0) close(fd_); fd_ = -1; } -- 2.11.0