From 076aad3fef29122b8d680b536c50cb714511e39a Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Fri, 1 May 2026 22:53:06 +0100 Subject: [PATCH] Coding - Fix CI compilation warnings (#1253) Refactor NULL to nullptr in OpenGL-related files Fix some MacOS, Ubuntu warnings and disable too strict warning checks --- .github/actions/configure-occt/action.yml | 9 ++++----- .../TKGeomAlgo/IntImp/IntImp_ZerImpFunc.gxx | 6 +++--- .../IntStart/IntStart_SearchOnBoundaries.gxx | 4 ++-- .../TKOpenGl/OpenGl/OpenGl_GlFunctions.cxx | 10 +++++----- .../TKOpenGl/OpenGl/OpenGl_GraphicDriver.cxx | 20 +++++++++---------- .../TKOpenGl/OpenGl/OpenGl_Window.cxx | 8 ++++---- .../TKOpenGl/OpenGl/OpenGl_Window_1.mm | 12 +++++------ .../TKService/Cocoa/Cocoa_Window.hxx | 4 ++-- 8 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.github/actions/configure-occt/action.yml b/.github/actions/configure-occt/action.yml index d919bb81ae..2ee57b784b 100644 --- a/.github/actions/configure-occt/action.yml +++ b/.github/actions/configure-occt/action.yml @@ -70,9 +70,9 @@ runs: brew update || true # temporary workaround for missing tcl-tk brew install tcl-tk || true - # Force link any conflicting packages - brew link --overwrite python@3.12 || true - brew link --overwrite python@3.13 || true + # Force link any conflicting packages (only if the keg is installed) + brew list python@3.12 >/dev/null 2>&1 && brew link --overwrite python@3.12 || true + brew list python@3.13 >/dev/null 2>&1 && brew link --overwrite python@3.13 || true shell: bash - name: Configure OCCT (Windows) @@ -152,7 +152,6 @@ runs: cmake -G "Unix Makefiles" \ -D CMAKE_C_COMPILER=${{ inputs.compiler == 'clang' && 'clang' || 'gcc' }} \ -D CMAKE_CXX_COMPILER=${{ inputs.compiler == 'clang' && 'clang++' || 'g++' }} \ - -D CMAKE_CXX_FLAGS="-Werror -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wno-error=array-bounds -Wno-error=maybe-uninitialized -Wno-error=stringop-overflow -Wno-deprecated-declarations -Wno-error=cast-function-type-mismatch" \ -D BUILD_USE_PCH=${{ inputs.build-use-pch }} \ -D BUILD_OPT_PROFILE=${{ inputs.build-opt-profile }} \ -D BUILD_INCLUDE_SYMLINK=ON \ @@ -168,6 +167,7 @@ runs: -D BUILD_GTEST=ON \ -D BUILD_CPP_STANDARD=C++17 \ -D INSTALL_GTEST=ON \ + -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wno-deprecated-declarations -Wno-unknown-warning-option -Wno-error=cast-function-type-mismatch" \ ${{ inputs.additional-cmake-flags }} .. echo "Configuration completed successfully for macOS" shell: bash @@ -183,7 +183,6 @@ runs: cmake -G "Unix Makefiles" \ -D CMAKE_C_COMPILER=${{ inputs.compiler == 'clang' && 'clang' || 'gcc' }} \ -D CMAKE_CXX_COMPILER=${{ inputs.compiler == 'clang' && 'clang++' || 'g++' }} \ - -D CMAKE_CXX_FLAGS="-Werror -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wno-error=array-bounds -Wno-error=maybe-uninitialized -Wno-error=stringop-overflow" \ -D BUILD_USE_PCH=${{ inputs.build-use-pch }} \ -D BUILD_INCLUDE_SYMLINK=ON \ -D BUILD_OPT_PROFILE=${{ inputs.build-opt-profile }} \ diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ZerImpFunc.gxx b/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ZerImpFunc.gxx index 9b0dfc6899..843f32ee0d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ZerImpFunc.gxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ZerImpFunc.gxx @@ -25,8 +25,8 @@ #define FUNC (*((TheISurface*)(func))) IntImp_ZerImpFunc::IntImp_ZerImpFunc() - : surf(NULL), - func(NULL), + : surf(nullptr), + func(nullptr), u(0.0), v(0.0), tol(0.0), @@ -55,7 +55,7 @@ IntImp_ZerImpFunc::IntImp_ZerImpFunc(const ThePSurface& PS, const TheISurface& I } IntImp_ZerImpFunc::IntImp_ZerImpFunc(const TheISurface& IS) - : surf(NULL), + : surf(nullptr), u(0.0), v(0.0), tol(0.0), diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntStart/IntStart_SearchOnBoundaries.gxx b/src/ModelingAlgorithms/TKGeomAlgo/IntStart/IntStart_SearchOnBoundaries.gxx index a6bc106670..98fd09e6e9 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntStart/IntStart_SearchOnBoundaries.gxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntStart/IntStart_SearchOnBoundaries.gxx @@ -1005,7 +1005,7 @@ void PointProcess(const gp_Pnt& Pt, bool IsRegularity(const TheArc& /*A*/, const occ::handle& aDomain) { void* anEAddress = aDomain->Edge(); - if (anEAddress == NULL) + if (anEAddress == nullptr) { return false; } @@ -1026,7 +1026,7 @@ int TreatLC(const TheArc& A, int anExitCode = 1, aNbExt; void* anEAddress = aDomain->Edge(); - if (anEAddress == NULL) + if (anEAddress == nullptr) { return anExitCode; } diff --git a/src/Visualization/TKOpenGl/OpenGl/OpenGl_GlFunctions.cxx b/src/Visualization/TKOpenGl/OpenGl/OpenGl_GlFunctions.cxx index dd351f4ffe..8e3e21a7d8 100644 --- a/src/Visualization/TKOpenGl/OpenGl/OpenGl_GlFunctions.cxx +++ b/src/Visualization/TKOpenGl/OpenGl/OpenGl_GlFunctions.cxx @@ -116,7 +116,7 @@ static void APIENTRY glGetTexLevelParameterfv(GLenum target, static void APIENTRY glGetPointerv(GLenum name, GLvoid** params) { #if defined(GL_ES_VERSION_2_0) - *params = NULL; + *params = nullptr; ::glEnable(0xFFFF); // added to OpenGL ES 3.2 (void)name; #else @@ -1913,7 +1913,7 @@ void OpenGl_GlFunctions::load(OpenGl_Context& theCtx, bool theIsCoreProfile) } #if defined(GL_ES_VERSION_2_0) - theCtx.core11ffp = NULL; + theCtx.core11ffp = nullptr; #else theCtx.core11ffp = !isCoreProfile ? (OpenGl_GlCore11*)this : nullptr; #endif @@ -2065,7 +2065,7 @@ void OpenGl_GlFunctions::load(OpenGl_Context& theCtx, bool theIsCoreProfile) #ifndef __EMSCRIPTEN__ && hasMapBufferRange #endif - && hasInstanced && theCtx.arbSamplerObject != NULL && theCtx.arbFBOBlit != NULL + && hasInstanced && theCtx.arbSamplerObject != nullptr && theCtx.arbFBOBlit != nullptr && FindProcShort(glReadBuffer) && FindProcShort(glDrawRangeElements) && FindProcShort(glTexImage3D) && FindProcShort(glTexSubImage3D) && FindProcShort(glCopyTexSubImage3D) && FindProcShort(glCompressedTexImage3D) @@ -2161,7 +2161,7 @@ void OpenGl_GlFunctions::load(OpenGl_Context& theCtx, bool theIsCoreProfile) if (isGlGreaterEqualShort(3, 2) || checkExtensionShort("GL_KHR_debug")) { // this functionality become a part of OpenGL ES 3.2 - theCtx.arbDbg = NULL; + theCtx.arbDbg = nullptr; if (isGlGreaterEqualShort(3, 2) && FindProcShort(glDebugMessageControl) && FindProcShort(glDebugMessageInsert) && FindProcShort(glDebugMessageCallback) && FindProcShort(glGetDebugMessageLog)) @@ -2182,7 +2182,7 @@ void OpenGl_GlFunctions::load(OpenGl_Context& theCtx, bool theIsCoreProfile) // load OpenGL ES 3.2 new functions const bool has32es = - isGlGreaterEqualShort(3, 2) && has31es && hasTexBuffer32 && theCtx.arbDbg != NULL + isGlGreaterEqualShort(3, 2) && has31es && hasTexBuffer32 && theCtx.arbDbg != nullptr && FindProcShort(glBlendBarrier) && FindProcShort(glCopyImageSubData) && FindProcShort(glPushDebugGroup) && FindProcShort(glPopDebugGroup) && FindProcShort(glObjectLabel) && FindProcShort(glGetObjectLabel) diff --git a/src/Visualization/TKOpenGl/OpenGl/OpenGl_GraphicDriver.cxx b/src/Visualization/TKOpenGl/OpenGl/OpenGl_GraphicDriver.cxx index 71d1a00021..32f4f2284d 100644 --- a/src/Visualization/TKOpenGl/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/Visualization/TKOpenGl/OpenGl/OpenGl_GraphicDriver.cxx @@ -80,7 +80,7 @@ static const occ::handle TheNullGlCtx; //! Wrapper over eglChooseConfig() called with preferred defaults. static EGLConfig chooseEglSurfConfig(EGLDisplay theDisplay, const occ::handle& theCaps) { - EGLConfig aCfg = NULL; + EGLConfig aCfg = nullptr; EGLint aNbConfigs = 0; for (int aGlesVer = 3; aGlesVer >= 2; --aGlesVer) { @@ -116,7 +116,7 @@ static EGLConfig chooseEglSurfConfig(EGLDisplay theDisplay, const occ::handle& theDriver, EGLContext anEglContext = (EGLContext)theDriver->getRawGlContext(); EGLConfig anEglConfig = (EGLConfig)theDriver->getRawGlConfig(); if (anEglDisplay == EGL_NO_DISPLAY || anEglContext == EGL_NO_CONTEXT - || (anEglConfig == NULL && (EGLContext)theGContext == EGL_NO_CONTEXT)) + || (anEglConfig == nullptr && (EGLContext)theGContext == EGL_NO_CONTEXT)) { throw Aspect_GraphicDeviceDefinitionError( "OpenGl_Window, EGL does not provide compatible configurations!"); @@ -215,7 +215,7 @@ void OpenGl_Window::Init(const occ::handle& theDriver, anEglSurf = eglCreateWindowSurface(anEglDisplay, anEglConfig, (EGLNativeWindowType)myPlatformWindow->NativeHandle(), - NULL); + nullptr); if (anEglSurf == EGL_NO_SURFACE && myPlatformWindow->NativeHandle() != 0) { throw Aspect_GraphicDeviceDefinitionError( @@ -226,7 +226,7 @@ void OpenGl_Window::Init(const occ::handle& theDriver, // window-less EGL context (off-screen) // throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL is unable to retrieve current // surface!"); - if (anEglConfig != NULL) + if (anEglConfig != nullptr) { #if !defined(__EMSCRIPTEN__) // eglCreatePbufferSurface() is not implemented by Emscripten EGL const int aSurfAttribs[] = {EGL_WIDTH, @@ -267,7 +267,7 @@ void OpenGl_Window::Init(const occ::handle& theDriver, // window-less EGL context (off-screen) // throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL is unable to retrieve current // surface!"); - if (anEglConfig != NULL) + if (anEglConfig != nullptr) { #if !defined(__EMSCRIPTEN__) // eglCreatePbufferSurface() is not implemented by Emscripten EGL const int aSurfAttribs[] = {EGL_WIDTH, diff --git a/src/Visualization/TKOpenGl/OpenGl/OpenGl_Window_1.mm b/src/Visualization/TKOpenGl/OpenGl/OpenGl_Window_1.mm index 0f407ee33c..01fcb9b472 100644 --- a/src/Visualization/TKOpenGl/OpenGl/OpenGl_Window_1.mm +++ b/src/Visualization/TKOpenGl/OpenGl/OpenGl_Window_1.mm @@ -136,10 +136,10 @@ void OpenGl_Window::Init (const occ::handle& theDriver, Cocoa_LocalPool aLocalPool; // all GL context within one OpenGl_GraphicDriver should be shared! - NSOpenGLContext* aGLCtxShare = theShareCtx.IsNull() ? NULL : theShareCtx->myGContext; + NSOpenGLContext* aGLCtxShare = theShareCtx.IsNull() ? nullptr : theShareCtx->myGContext; NSOpenGLContext* aGLContext = theGContext; bool isCore = false; - if (aGLContext == NULL) + if (aGLContext == nullptr) { NSOpenGLPixelFormatAttribute anAttribs[32] = {}; int aLastAttrib = 0; @@ -195,19 +195,19 @@ void OpenGl_Window::Init (const occ::handle& theDriver, NSOpenGLPixelFormat* aGLFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes: anAttribs] autorelease]; aGLContext = [[NSOpenGLContext alloc] initWithFormat: aGLFormat shareContext: aGLCtxShare]; - if (aGLContext != NULL) + if (aGLContext != nullptr) { break; } } - if (aGLContext != NULL) + if (aGLContext != nullptr) { break; } } - if (aGLContext == NULL) + if (aGLContext == nullptr) { TCollection_AsciiString aMsg ("OpenGl_Window::CreateWindow: NSOpenGLContext creation failed"); throw Aspect_GraphicDeviceDefinitionError(aMsg.ToCString()); @@ -402,7 +402,7 @@ void OpenGl_Window::init() const int aViewport[4] = { 0, 0, mySize.x(), mySize.y() }; myGlContext->ResizeViewport (aViewport); myGlContext->SetDrawBuffer (GL_BACK); - if (myGlContext->core11ffp != NULL) + if (myGlContext->core11ffp != nullptr) { myGlContext->core11ffp->glMatrixMode (GL_MODELVIEW); } diff --git a/src/Visualization/TKService/Cocoa/Cocoa_Window.hxx b/src/Visualization/TKService/Cocoa/Cocoa_Window.hxx index dc163ad715..d61af78147 100644 --- a/src/Visualization/TKService/Cocoa/Cocoa_Window.hxx +++ b/src/Visualization/TKService/Cocoa/Cocoa_Window.hxx @@ -127,7 +127,7 @@ public: virtual Aspect_Drawable NativeParentHandle() const override { return 0; } //! Returns nothing on OS X - virtual Aspect_FBConfig NativeFBConfig() const override { return NULL; } + virtual Aspect_FBConfig NativeFBConfig() const override { return nullptr; } //! Sets window title. Standard_EXPORT virtual void SetTitle(const TCollection_AsciiString& theTitle) override; @@ -135,7 +135,7 @@ public: //! Invalidate entire window content by setting NSView::setNeedsDisplay property. //! Call will be implicitly redirected to the main thread when called from non-GUI thread. Standard_EXPORT virtual void InvalidateContent( - const occ::handle& theDisp = NULL) override; + const occ::handle& theDisp = nullptr) override; protected: #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE