Fixed Windows warnings - Removed unused variables - Removed unreachable code - Fixed size_t <-> int conversions - Fixed uninitialized variables Change-Id: Ifc3912e92b8f0710094e939bd0da4757148b559a Reviewed-on: https://swiftshader-review.googlesource.com/5681 Tested-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/ConstantUnion.h b/src/OpenGL/compiler/ConstantUnion.h index 27f816c..6b1050f 100644 --- a/src/OpenGL/compiler/ConstantUnion.h +++ b/src/OpenGL/compiler/ConstantUnion.h
@@ -152,8 +152,6 @@ default: return false; } - - return false; } bool operator!=(const int i) const @@ -194,8 +192,6 @@ default: return false; // Invalid operation, handled at semantic analysis } - - return false; } bool operator<(const ConstantUnion& constant) const @@ -211,8 +207,6 @@ default: return false; // Invalid operation, handled at semantic analysis } - - return false; } bool operator<=(const ConstantUnion& constant) const @@ -228,8 +222,6 @@ default: return false; // Invalid operation, handled at semantic analysis } - - return false; } bool operator>=(const ConstantUnion& constant) const @@ -245,8 +237,6 @@ default: return false; // Invalid operation, handled at semantic analysis } - - return false; } ConstantUnion operator+(const ConstantUnion& constant) const
diff --git a/src/OpenGL/libEGL/Display.cpp b/src/OpenGL/libEGL/Display.cpp index 387d23e..63ad1ea 100644 --- a/src/OpenGL/libEGL/Display.cpp +++ b/src/OpenGL/libEGL/Display.cpp
@@ -542,13 +542,13 @@ return status == True; } + return false; #elif defined(__APPLE__) return sw::OSX::IsValidWindow(window); #else #error "Display::isValidWindow unimplemented for this platform" + return false; #endif - - return false; } bool Display::hasExistingWindowSurface(EGLNativeWindowType window)
diff --git a/src/OpenGL/libEGL/libEGL.cpp b/src/OpenGL/libEGL/libEGL.cpp index a85d301..4fa1cf3 100644 --- a/src/OpenGL/libEGL/libEGL.cpp +++ b/src/OpenGL/libEGL/libEGL.cpp
@@ -1043,17 +1043,15 @@ { TRACE("(EGLenum platform = 0x%X, void *native_display = %p, const EGLint *attrib_list = %p)", platform, native_display, attrib_list); - switch(platform) - { #if defined(__linux__) && !defined(__ANDROID__) - case EGL_PLATFORM_X11_EXT: break; - case EGL_PLATFORM_GBM_KHR: break; - #endif - default: - return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); - } + switch(platform) + { + case EGL_PLATFORM_X11_EXT: break; + case EGL_PLATFORM_GBM_KHR: break; + default: + return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); + } - #if defined(__linux__) && !defined(__ANDROID__) if(platform == EGL_PLATFORM_X11_EXT) { if(!libX11) @@ -1075,9 +1073,11 @@ return success(HEADLESS_DISPLAY); } - #endif - return success(PRIMARY_DISPLAY); // We only support the default display + return success(PRIMARY_DISPLAY); // We only support the default display + #else + return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); + #endif } EGLSurface CreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list)
diff --git a/src/OpenGL/libGLESv2/IndexDataManager.cpp b/src/OpenGL/libGLESv2/IndexDataManager.cpp index 8405aea..2bdd596 100644 --- a/src/OpenGL/libGLESv2/IndexDataManager.cpp +++ b/src/OpenGL/libGLESv2/IndexDataManager.cpp
@@ -125,7 +125,7 @@ } else { - unsigned int streamOffset = 0; + size_t streamOffset = 0; int convertCount = count; streamingBuffer->reserveSpace(convertCount * typeSize(type), type); @@ -143,7 +143,7 @@ computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); translated->indexBuffer = streamingBuffer->getResource(); - translated->indexOffset = streamOffset; + translated->indexOffset = static_cast<unsigned int>(streamOffset); } if(translated->minIndex < start || translated->maxIndex > end) @@ -165,7 +165,7 @@ } } -StreamingIndexBuffer::StreamingIndexBuffer(unsigned int initialSize) : mIndexBuffer(NULL), mBufferSize(initialSize) +StreamingIndexBuffer::StreamingIndexBuffer(size_t initialSize) : mIndexBuffer(NULL), mBufferSize(initialSize) { if(initialSize > 0) { @@ -188,7 +188,7 @@ } } -void *StreamingIndexBuffer::map(unsigned int requiredSpace, unsigned int *offset) +void *StreamingIndexBuffer::map(size_t requiredSpace, size_t *offset) { void *mapPtr = NULL; @@ -217,7 +217,7 @@ } } -void StreamingIndexBuffer::reserveSpace(unsigned int requiredSpace, GLenum type) +void StreamingIndexBuffer::reserveSpace(size_t requiredSpace, GLenum type) { if(requiredSpace > mBufferSize) {
diff --git a/src/OpenGL/libGLESv2/IndexDataManager.h b/src/OpenGL/libGLESv2/IndexDataManager.h index 225e30c..0a5e398 100644 --- a/src/OpenGL/libGLESv2/IndexDataManager.h +++ b/src/OpenGL/libGLESv2/IndexDataManager.h
@@ -37,19 +37,19 @@ class StreamingIndexBuffer { public: - StreamingIndexBuffer(unsigned int initialSize); + StreamingIndexBuffer(size_t initialSize); virtual ~StreamingIndexBuffer(); - void *map(unsigned int requiredSpace, unsigned int *offset); + void *map(size_t requiredSpace, size_t *offset); void unmap(); - void reserveSpace(unsigned int requiredSpace, GLenum type); + void reserveSpace(size_t requiredSpace, GLenum type); sw::Resource *getResource() const; private: sw::Resource *mIndexBuffer; - unsigned int mBufferSize; - unsigned int mWritePosition; + size_t mBufferSize; + size_t mWritePosition; }; class IndexDataManager
diff --git a/src/OpenGL/libGLESv2/utilities.cpp b/src/OpenGL/libGLESv2/utilities.cpp index 9d22290..841bcab 100644 --- a/src/OpenGL/libGLESv2/utilities.cpp +++ b/src/OpenGL/libGLESv2/utilities.cpp
@@ -776,7 +776,7 @@ return error(GL_INVALID_ENUM, false); } - if(internalformat != format) + if((GLenum)internalformat != format) { if(clientVersion < 3) { @@ -993,7 +993,7 @@ #undef VALIDATE_INTERNALFORMAT - if(internalformat != format && !validSizedInternalformat) + if((GLenum)internalformat != format && !validSizedInternalformat) { return error(GL_INVALID_OPERATION, false); }