From: tiv Date: Wed, 16 Oct 2019 17:47:30 +0000 (+0300) Subject: 0030609: Coding - eliminate warnings issued by gcc 8.1.0 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=d478b270386b52926641aedad4c086a2ccdfc37f;p=occt-copy.git 0030609: Coding - eliminate warnings issued by gcc 8.1.0 Warnings issued by gcc 8.1.0 are eliminated. New function OSD_FunctionCast() is introduced to explicitly mark places where the conversion from the pointer to one function type to the pointer to another function type takes place and to suppress gcc warning "-Wcast-function-type" (introduced in gcc 8.1.0). --- diff --git a/src/BiTgte/BiTgte_Blend.cxx b/src/BiTgte/BiTgte_Blend.cxx index 6bbb10245b..77c0ae4b47 100644 --- a/src/BiTgte/BiTgte_Blend.cxx +++ b/src/BiTgte/BiTgte_Blend.cxx @@ -1192,35 +1192,42 @@ BiTgte_ContactType BiTgte_Blend::ContactType(const Standard_Integer Index) } BiTgte_ContactType Type = BiTgte_VertexVertex; - switch (Type1) { - - case TopAbs_VERTEX: - switch (Type2) { - case TopAbs_VERTEX: Type = BiTgte_VertexVertex; break; - case TopAbs_EDGE: Type = BiTgte_EdgeVertex; break; - case TopAbs_FACE: Type = BiTgte_FaceVertex; break; - default: + switch (Type1) + { + case TopAbs_VERTEX: + switch (Type2) + { + case TopAbs_VERTEX: Type = BiTgte_VertexVertex; break; + case TopAbs_EDGE: Type = BiTgte_EdgeVertex; break; + case TopAbs_FACE: Type = BiTgte_FaceVertex; break; + default: + break; + } break; - } - - case TopAbs_EDGE: - switch (Type2) { - case TopAbs_EDGE: Type = BiTgte_EdgeEdge; break; - case TopAbs_FACE: Type = BiTgte_FaceEdge; break; - default: + + case TopAbs_EDGE: + switch (Type2) + { + case TopAbs_EDGE: Type = BiTgte_EdgeEdge; break; + case TopAbs_FACE: Type = BiTgte_FaceEdge; break; + default: + break; + } break; - } - - case TopAbs_FACE: - switch (Type2) { - case TopAbs_FACE: Type = BiTgte_FaceEdge; break; + + case TopAbs_FACE: + switch (Type2) + { + case TopAbs_FACE: Type = BiTgte_FaceEdge; break; + default: + break; + } + break; + default: break; - } - default: - break; } - + return Type; } diff --git a/src/D3DHost/D3DHost_View.cxx b/src/D3DHost/D3DHost_View.cxx index 6b9f76baea..df3846de5e 100644 --- a/src/D3DHost/D3DHost_View.cxx +++ b/src/D3DHost/D3DHost_View.cxx @@ -19,6 +19,7 @@ #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(D3DHost_View,OpenGl_View) @@ -143,7 +144,7 @@ bool D3DHost_View::d3dInitLib() { // retrieve D3D9Ex function dynamically (available only since Vista+) typedef HRESULT (WINAPI* Direct3DCreate9Ex_t)(UINT , IDirect3D9Ex** ); - Direct3DCreate9Ex_t Direct3DCreate9ExProc = (Direct3DCreate9Ex_t )GetProcAddress (aLib, "Direct3DCreate9Ex"); + Direct3DCreate9Ex_t Direct3DCreate9ExProc = OSD_FunctionCast (GetProcAddress (aLib, "Direct3DCreate9Ex")); if (Direct3DCreate9ExProc != NULL) { Direct3DCreate9ExProc(D3D_SDK_VERSION, &aD3dLibEx); diff --git a/src/Draw/Draw.cxx b/src/Draw/Draw.cxx index f0a27e42da..0812529ca7 100644 --- a/src/Draw/Draw.cxx +++ b/src/Draw/Draw.cxx @@ -278,7 +278,7 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) typedef BOOL (WINAPI *SetDllDirectoryW_t)(const wchar_t* thePathName); HMODULE aKern32Module = GetModuleHandleW (L"kernel32"); SetDllDirectoryW_t aFunc = (aKern32Module != NULL) - ? (SetDllDirectoryW_t )GetProcAddress (aKern32Module, "SetDllDirectoryW") : NULL; + ? OSD_FunctionCast (GetProcAddress (aKern32Module, "SetDllDirectoryW")) : NULL; if (aFunc != NULL) { aFunc (aUserDllPath.ToWideString()); @@ -724,8 +724,7 @@ void Draw::Load(Draw_Interpretor& theDI, const TCollection_AsciiString& theKey, // fp = (void (*)(Draw_Interpretor&, const TCollection_AsciiString&)) f; // (*fp) (theDI, theKey); - void (*fp) (Draw_Interpretor&) = NULL; - fp = (void (*)(Draw_Interpretor&)) f; + void (*fp) (Draw_Interpretor&) = OSD_FunctionCast (f); (*fp) (theDI); } diff --git a/src/Draw/Draw_Window.cxx b/src/Draw/Draw_Window.cxx index 4602f31b57..f096767e67 100644 --- a/src/Draw/Draw_Window.cxx +++ b/src/Draw/Draw_Window.cxx @@ -2003,7 +2003,7 @@ void Segment::Init(Standard_Integer a1, Standard_Integer a2, y2=a4; } -static DWORD WINAPI tkLoop(VOID); +static DWORD WINAPI tkLoop (LPVOID theThreadParameter); #ifdef _TK static Tk_Window mainWindow; #endif @@ -2027,12 +2027,12 @@ Standard_Boolean Init_Appli(HINSTANCE hInst, dwMainThreadId = GetCurrentThreadId(); //necessary for normal Tk operation - hThread = CreateThread(NULL, // no security attributes - 0, // use default stack size - (LPTHREAD_START_ROUTINE) tkLoop, // thread function - NULL, // no thread function argument - 0, // use default creation flags - &IDThread); + hThread = CreateThread (NULL, // no security attributes + 0, // use default stack size + tkLoop, // thread function + NULL, // no thread function argument + 0, // use default creation flags + &IDThread); if (!hThread) { std::cout << "Failed to create Tcl/Tk main loop thread. Switching to batch mode..." << std::endl; Draw_Batch = Standard_True; @@ -2082,8 +2082,9 @@ Standard_Boolean Draw_Interprete (const char*); /*--------------------------------------------------------*\ | readStdinThreadFunc \*--------------------------------------------------------*/ -static DWORD WINAPI readStdinThreadFunc() +static DWORD WINAPI readStdinThreadFunc (const LPVOID theThreadParameter) { + (void)theThreadParameter; if (!Draw_IsConsoleSubsystem) { return 1; @@ -2246,8 +2247,9 @@ static void ResetStdChannel (int type) /*--------------------------------------------------------*\ | tkLoop: implements Tk_Main()-like behaviour in a separate thread \*--------------------------------------------------------*/ -static DWORD WINAPI tkLoop(VOID) +static DWORD WINAPI tkLoop (const LPVOID theThreadParameter) { + (void)theThreadParameter; Tcl_CreateExitHandler(exitProc, 0); Draw_Interpretor& aCommands = Draw::GetInterpretor(); @@ -2309,7 +2311,7 @@ static DWORD WINAPI tkLoop(VOID) #endif } } - catch (Standard_Failure) + catch (const Standard_Failure&) { std::cout << "tkLoop: exception in TK_Init\n"; } @@ -2389,12 +2391,12 @@ void Run_Appli(HWND hWnd) DWORD IDThread; HANDLE hThread; if (Draw_IsConsoleSubsystem) { - hThread = CreateThread(NULL, // no security attributes - 0, // use default stack size - (LPTHREAD_START_ROUTINE) readStdinThreadFunc, // thread function - NULL, // no thread function argument - 0, // use default creation flags - &IDThread); // returns thread identifier + hThread = CreateThread (NULL, // no security attributes + 0, // use default stack size + readStdinThreadFunc, // thread function + NULL, // no thread function argument + 0, // use default creation flags + &IDThread); // returns thread identifier if (!hThread) { std::cout << "pb in creation of the thread reading stdin" << std::endl; Draw_IsConsoleSubsystem = Standard_False; diff --git a/src/Message/Message_MsgFile.cxx b/src/Message/Message_MsgFile.cxx index 2c5deba4f4..22ffbbc56f 100644 --- a/src/Message/Message_MsgFile.cxx +++ b/src/Message/Message_MsgFile.cxx @@ -257,7 +257,7 @@ Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName) { // Reverse the bytes throughout the buffer const Standard_ExtCharacter* const anEnd = - reinterpret_cast(&anMsgBuffer[aFileSize]); + reinterpret_cast(&anMsgBuffer[aFileSize]); for (Standard_ExtCharacter* aPtr = aUnicodeBuffer; aPtr < anEnd; aPtr++) { diff --git a/src/OSD/OSD_Function.hxx b/src/OSD/OSD_Function.hxx index 695dd905cf..7050ceed46 100644 --- a/src/OSD/OSD_Function.hxx +++ b/src/OSD/OSD_Function.hxx @@ -15,9 +15,44 @@ #ifndef OSD_Function_HeaderFile #define OSD_Function_HeaderFile +#include + // This is in fact a pointer to a function. // This is not an "enumeration" but a trick to solve an omission from CDL. typedef int (* OSD_Function)(...); +//! Converts the given pointer to function @p theFromFunction +//! to the type of the pointer to function specified as the first template argument @p TheToFunction. +//! This function is necessary to explicitly mark the places where such conversion takes place +//! and to suppress @em gcc warning @c -Wcast-function-type. +//! @tparam TheToFunction the type to which the given pointer to function must be casted +//! (it may be the type of the function or the type of the pointer to function) +//! @tparam TheFromFunction the type of the function to be casted +//! @tparam AToFunction it is not an actual template parameter, +//! but a simple alias needed to reduce the amount of boilerplate +//! @param theFromFunction the pointer to the function to be casted +//! @return the pointer of the function of type @c AToFunction* that is the result of the cast +template ::type> +typename opencascade::std::enable_if::value + && opencascade::std::is_function::value, + AToFunction*>::type +OSD_FunctionCast (TheFromFunction* const theFromFunction) +{ +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__) +# if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-function-type" +# endif +#endif + return reinterpret_cast (theFromFunction); +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__) +# if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1)) +# pragma GCC diagnostic pop +# endif +#endif +} + #endif diff --git a/src/OSD/OSD_Parallel.cxx b/src/OSD/OSD_Parallel.cxx index 97d502aad7..593601aa91 100644 --- a/src/OSD/OSD_Parallel.cxx +++ b/src/OSD/OSD_Parallel.cxx @@ -16,6 +16,8 @@ #include +#include + #ifdef _WIN32 #include #include @@ -42,7 +44,7 @@ namespace { HMODULE aKern32Module = GetModuleHandleW(L"kernel32"); LPFN_ISWOW64PROCESS aFunIsWow64 = (aKern32Module == NULL) ? (LPFN_ISWOW64PROCESS )NULL - : (LPFN_ISWOW64PROCESS)GetProcAddress(aKern32Module, "IsWow64Process"); + : OSD_FunctionCast (GetProcAddress(aKern32Module, "IsWow64Process")); return aFunIsWow64 != NULL && aFunIsWow64(GetCurrentProcess(), &bIsWow64) && @@ -221,7 +223,7 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors() typedef BOOL (WINAPI *LPFN_GSI)(LPSYSTEM_INFO ); HMODULE aKern32 = GetModuleHandleW(L"kernel32"); - LPFN_GSI aFuncSysInfo = (LPFN_GSI )GetProcAddress(aKern32, "GetNativeSystemInfo"); + LPFN_GSI aFuncSysInfo = OSD_FunctionCast (GetProcAddress(aKern32, "GetNativeSystemInfo")); // So, they suggest 32-bit apps should call this instead of the other in WOW64 if ( aFuncSysInfo != NULL ) diff --git a/src/OSD/OSD_SharedLibrary.cxx b/src/OSD/OSD_SharedLibrary.cxx index b635baad31..0345f61efe 100644 --- a/src/OSD/OSD_SharedLibrary.cxx +++ b/src/OSD/OSD_SharedLibrary.cxx @@ -266,7 +266,7 @@ Standard_Boolean OSD_SharedLibrary :: DlOpen ( const OSD_LoadMode /*Mode*/ ) { OSD_Function OSD_SharedLibrary :: DlSymb ( const Standard_CString Name ) const { - OSD_Function func = ( OSD_Function )GetProcAddress ( ( HMODULE )myHandle, Name ); + OSD_Function func = OSD_FunctionCast (GetProcAddress ((HMODULE)myHandle, Name)); if ( func == NULL ) diff --git a/src/OSD/OSD_WNT.cxx b/src/OSD/OSD_WNT.cxx index ef38d808fa..f7acbd190f 100644 --- a/src/OSD/OSD_WNT.cxx +++ b/src/OSD/OSD_WNT.cxx @@ -699,12 +699,13 @@ retry: if (retVal || (!retVal && GetLastError() == ERROR_ALREADY_EXISTS)) { size_t anOldDirLength; - StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength); + StringCchLengthW (oldDir, MAX_PATH, &anOldDirLength); + const size_t aNameLength = anOldDirLength + WILD_CARD_LEN + sizeof (L'\x00'); if ((pFD = (WIN32_FIND_DATAW* )HeapAlloc (hHeap, 0, sizeof(WIN32_FIND_DATAW))) != NULL - && (pName = (wchar_t* )HeapAlloc (hHeap, 0, anOldDirLength + WILD_CARD_LEN + sizeof(L'\x00'))) != NULL) + && (pName = (wchar_t* )HeapAlloc (hHeap, 0, aNameLength)) != NULL) { - StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), oldDir); - StringCchCatW (pName, sizeof(pName), WILD_CARD); + StringCchCopyW (pName, aNameLength, oldDir); + StringCchCatW (pName, aNameLength, WILD_CARD); retVal = TRUE; hFindFile = FindFirstFileExW (pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0); for (BOOL fFind = hFindFile != INVALID_HANDLE_VALUE; fFind; fFind = FindNextFileW (hFindFile, pFD)) @@ -715,23 +716,24 @@ retry: continue; } - size_t anOldDirLength2 = 0, aNewDirLength = 0, aFileNameLength = 0; - StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength2); - StringCchLengthW (newDir, sizeof(newDir) / sizeof(newDir[0]), &aNewDirLength); + size_t aNewDirLength = 0, aFileNameLength = 0; + StringCchLengthW (newDir, MAX_PATH, &aNewDirLength); StringCchLengthW (pFD->cFileName, sizeof(pFD->cFileName) / sizeof(pFD->cFileName[0]), &aFileNameLength); - if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, anOldDirLength2 + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL - || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aNewDirLength + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL) + const size_t aFullNameSrcLength = anOldDirLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00'); + const size_t aFullNameDstLength = aNewDirLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00'); + if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameSrcLength)) == NULL + || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameDstLength)) == NULL) { break; } - StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), oldDir); - StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/"); - StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName); + StringCchCopyW (pFullNameSrc, aFullNameSrcLength, oldDir); + StringCchCatW (pFullNameSrc, aFullNameSrcLength, L"/"); + StringCchCatW (pFullNameSrc, aFullNameSrcLength, pFD->cFileName); - StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), newDir); - StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/"); - StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName); + StringCchCopyW (pFullNameDst, aFullNameDstLength, newDir); + StringCchCatW (pFullNameDst, aFullNameDstLength, L"/"); + StringCchCatW (pFullNameDst, aFullNameDstLength, pFD->cFileName); if ((pFD->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { @@ -853,12 +855,13 @@ BOOL CopyDirectory (const wchar_t* dirSrc, const wchar_t* dirDst) if (retVal || (!retVal && GetLastError() == ERROR_ALREADY_EXISTS)) { size_t aDirSrcLength = 0; - StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength); + StringCchLengthW (dirSrc, MAX_PATH, &aDirSrcLength); + const size_t aNameLength = aDirSrcLength + WILD_CARD_LEN + sizeof (L'\x00'); if ((pFD = (WIN32_FIND_DATAW* )HeapAlloc (hHeap, 0, sizeof(WIN32_FIND_DATAW))) != NULL - && (pName = (wchar_t* )HeapAlloc (hHeap, 0, aDirSrcLength + WILD_CARD_LEN + sizeof(L'\x00'))) != NULL) + && (pName = (wchar_t* )HeapAlloc (hHeap, 0, aNameLength)) != NULL) { - StringCchCopyW(pName, sizeof(pName) / sizeof(pName[0]), dirSrc); - StringCchCatW (pName, sizeof(pName) / sizeof(pName[0]), WILD_CARD); + StringCchCopyW(pName, aNameLength, dirSrc); + StringCchCatW (pName, aNameLength, WILD_CARD); retVal = TRUE; hFindFile = FindFirstFileExW (pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0); @@ -870,23 +873,24 @@ BOOL CopyDirectory (const wchar_t* dirSrc, const wchar_t* dirDst) continue; } - size_t aDirSrcLength2 = 0, aDirDstLength = 0, aFileNameLength = 0; - StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength2); - StringCchLengthW (dirDst, sizeof(dirDst) / sizeof(dirDst[0]), &aDirDstLength); + size_t aDirDstLength = 0, aFileNameLength = 0; + StringCchLengthW (dirDst, MAX_PATH, &aDirDstLength); StringCchLengthW (pFD->cFileName, sizeof(pFD->cFileName) / sizeof(pFD->cFileName[0]), &aFileNameLength); - if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, aDirSrcLength2 + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL - || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aDirDstLength + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL) + const size_t aFullNameSrcLength = aDirSrcLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00'); + const size_t aFullNameDstLength = aDirDstLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00'); + if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameSrcLength)) == NULL + || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameDstLength)) == NULL) { break; } - StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), dirSrc); - StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/"); - StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName); + StringCchCopyW (pFullNameSrc, aFullNameSrcLength, dirSrc); + StringCchCatW (pFullNameSrc, aFullNameSrcLength, L"/"); + StringCchCatW (pFullNameSrc, aFullNameSrcLength, pFD->cFileName); - StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), dirDst); - StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/"); - StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName); + StringCchCopyW (pFullNameDst, aFullNameDstLength, dirDst); + StringCchCatW (pFullNameDst, aFullNameDstLength, L"/"); + StringCchCatW (pFullNameDst, aFullNameDstLength, pFD->cFileName); if ((pFD->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { retVal = CopyDirectory (pFullNameSrc, pFullNameDst); diff --git a/src/OSD/OSD_signal.cxx b/src/OSD/OSD_signal.cxx index 654523afd9..3a43672d3d 100644 --- a/src/OSD/OSD_signal.cxx +++ b/src/OSD/OSD_signal.cxx @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -273,7 +274,7 @@ static void SIGWntHandler (int signum, int sub_code) Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling switch( signum ) { case SIGFPE : - if ( signal( signum , (void(*)(int))SIGWntHandler ) == SIG_ERR ) + if (signal (signum, OSD_FunctionCast (SIGWntHandler)) == SIG_ERR) std::cout << "signal error" << std::endl ; switch( sub_code ) { case _FPE_INVALID : @@ -301,12 +302,12 @@ static void SIGWntHandler (int signum, int sub_code) } break ; case SIGSEGV : - if ( signal( signum, (void(*)(int))SIGWntHandler ) == SIG_ERR ) + if (signal (signum, OSD_FunctionCast (SIGWntHandler)) == SIG_ERR) std::cout << "signal error" << std::endl ; CallHandler( EXCEPTION_ACCESS_VIOLATION ,0,0) ; break ; case SIGILL : - if ( signal( signum, (void(*)(int))SIGWntHandler ) == SIG_ERR ) + if (signal (signum, OSD_FunctionCast (SIGWntHandler)) == SIG_ERR) std::cout << "signal error" << std::endl ; CallHandler( EXCEPTION_ILLEGAL_INSTRUCTION ,0,0) ; break ; @@ -452,7 +453,7 @@ void OSD::SetSignal (OSD_SignalMode theSignalMode, SignalFuncType aPreviousFunc = SIG_DFL; if (theSignalMode == OSD_SignalMode_Set || theSignalMode == OSD_SignalMode_SetUnhandled) { - aPreviousFunc = signal(aSignalTypes[i], (SignalFuncType)SIGWntHandler); + aPreviousFunc = signal (aSignalTypes[i], OSD_FunctionCast (SIGWntHandler)); } if (theSignalMode == OSD_SignalMode_Unset || (theSignalMode == OSD_SignalMode_SetUnhandled && aPreviousFunc != SIG_DFL && aPreviousFunc != SIG_ERR)) diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index c812775bca..45a5cdb89a 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -338,15 +339,15 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver, wglMakeCurrent (aDevCtxTmp, aRendCtxTmp); typedef const char* (WINAPI *wglGetExtensionsStringARB_t)(HDC theDeviceContext); - wglGetExtensionsStringARB_t aGetExtensions = (wglGetExtensionsStringARB_t )wglGetProcAddress ("wglGetExtensionsStringARB"); + wglGetExtensionsStringARB_t aGetExtensions = OSD_FunctionCast (wglGetProcAddress ("wglGetExtensionsStringARB")); const char* aWglExts = (aGetExtensions != NULL) ? aGetExtensions (wglGetCurrentDC()) : NULL; if (OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_pixel_format")) { - aChoosePixProc = (wglChoosePixelFormatARB_t )wglGetProcAddress ("wglChoosePixelFormatARB"); + aChoosePixProc = OSD_FunctionCast (wglGetProcAddress ("wglChoosePixelFormatARB")); } if (OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_create_context_profile")) { - aCreateCtxProc = (wglCreateContextAttribsARB_t )wglGetProcAddress ("wglCreateContextAttribsARB"); + aCreateCtxProc = OSD_FunctionCast (wglGetProcAddress ("wglCreateContextAttribsARB")); } } @@ -525,7 +526,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver, typedef GLXContext (*glXCreateContextAttribsARB_t)(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int* attrib_list); - glXCreateContextAttribsARB_t aCreateCtxProc = (glXCreateContextAttribsARB_t )glXGetProcAddress((const GLubyte* )"glXCreateContextAttribsARB"); + glXCreateContextAttribsARB_t aCreateCtxProc = OSD_FunctionCast (glXGetProcAddress((const GLubyte* )"glXCreateContextAttribsARB")); if (!theCaps->contextCompatible) { int aCoreCtxAttribs[] = diff --git a/src/Plugin/Plugin.cxx b/src/Plugin/Plugin.cxx index b478296f89..63b1a1bbd7 100644 --- a/src/Plugin/Plugin.cxx +++ b/src/Plugin/Plugin.cxx @@ -92,9 +92,8 @@ Handle(Standard_Transient) Plugin::Load (const Standard_GUID& aGUID, } else f = theMapOfFunctions(pid); - - Standard_Transient* (*fp) (const Standard_GUID&) = NULL; - fp = (Standard_Transient* (*)(const Standard_GUID&)) f; + + Standard_Transient* (*fp) (const Standard_GUID&) = OSD_FunctionCast (f); Handle(Standard_Transient) theServiceFactory = (*fp) (aGUID); return theServiceFactory; diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index 8a7ab78d29..3d81fbf3f5 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -3154,7 +3154,7 @@ static Standard_Integer OCC30708_1 (Draw_Interpretor& di, Standard_Integer, cons it.Initialize (empty); } - catch (Standard_Failure) + catch (const Standard_Failure&) { di << "Cannot initialize TopoDS_Iterator with null shape\n"; return 0; @@ -3179,7 +3179,7 @@ static Standard_Integer OCC30708_2 (Draw_Interpretor& di, Standard_Integer, cons TopoDS_Wire empty; BRepLib_MakeWire aWBuilder (empty); } - catch (Standard_Failure) + catch (const Standard_Failure&) { di << "Cannot initialize BRepLib_MakeWire with null wire\n"; } diff --git a/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx b/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx index 401c89699e..dfbcaea2c5 100644 --- a/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx +++ b/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx @@ -830,66 +830,6 @@ static Standard_Integer closefreebounds (Draw_Interpretor& di, } -//======================================================================= -//function : MyVISEDG -//purpose : -//======================================================================= -static Standard_Integer MyVISEDG (Draw_Interpretor& /*di*/, - Standard_Integer n, const char** a) -{ - if (n >4) return 1; - TopoDS_Shape MaListe = DBRep::Get(a[1]); - if (MaListe.IsNull()) return 1; - TopoDS_Compound TheList = TopoDS::Compound(MaListe); - if (TheList.IsNull()) return 1; - Standard_Real toler = 0.001; - int create = 0; - if ( n >= 3) toler = Draw::Atof(a[2]); - if (n == 4 && !strcmp(a[3],"C")) create = 1; - ShapeAnalysis_FreeBounds F(TheList,toler); - // - // - // - char name[100]; - char num[5]; - if (!create) - { - TopoDS_Compound Wires = F.GetClosedWires(); - TopoDS_Iterator S(Wires); - Standard_Integer iwire = 0; - while (S.More()) - { - Sprintf (num,"%d",iwire); - name[0] = 'w'; - name[1] = '\0'; - strncat(name,num,strlen(num)); - name[strlen(name)] = '\0'; - DBRep::Set(name,S.Value()); - S.Next(); - iwire++; - } - iwire = 0; - TopoDS_Compound Edges = F.GetOpenWires(); - S.Initialize(Edges); - iwire = 0; - while (S.More()) - { - Sprintf (num,"%d",iwire); - name[0] = 'E'; - name[1] = '\0'; - strncat(name,num,strlen(num)); - name[strlen(name)] = '\0'; - DBRep::Set(name,S.Value()); - S.Next(); - iwire++; - } - } - else - { - } - return 0; -} - static Standard_Integer getareacontour (Draw_Interpretor& di, Standard_Integer n, const char** a) { @@ -1076,10 +1016,7 @@ static Standard_Integer checkedge(Draw_Interpretor& di, Standard_Integer argc, c theCommands.Add("fbclose", "shp sewtoler closetoler [splitclosed [splitopen]] - closes free bounds; use sewtoler <= 0 for shells (no sewing call)", __FILE__, closefreebounds, groupold); - theCommands.Add("K_VISEDG", - "K_VISEDG Visu of free edge of a compound of faces.", - __FILE__, MyVISEDG, groupold); - + theCommands.Add("getareacontour","wire ",__FILE__, getareacontour, groupold); theCommands.Add ("checkselfintersection","wire [face]", __FILE__,checkselfintersection,g); theCommands.Add ("checkedge","edge [face]", __FILE__,checkedge,g);