From 85bb706900bab5febd461010d43cf709a7900f0c Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:35:29 +0100 Subject: [PATCH 1/9] Changed: Use ADD_PLATFORM_LINKFLAGS macro --HG-- branch : develop --- code/CMakeModules/nel.cmake | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index f44f146d6..3aa9d66bc 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -793,7 +793,7 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ENDIF() IF(TARGET_ARMV7) @@ -803,7 +803,7 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ENDIF() IF(TARGET_ARMV6) @@ -813,7 +813,7 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ENDIF() ENDIF() @@ -825,7 +825,7 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}") IF(CMAKE_OSX_DEPLOYMENT_TARGET) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") ENDIF() ENDIF() ELSE() @@ -834,7 +834,7 @@ MACRO(NL_SETUP_BUILD) IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.7") MESSAGE(FATAL_ERROR "Minimum target for OS X is 10.7 but you're using ${CMAKE_OSX_DEPLOYMENT_TARGET}") ENDIF() - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") + ADD_PLATFORM_LINKFLAGS("-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") ENDIF() ENDIF() @@ -845,7 +845,7 @@ MACRO(NL_SETUP_BUILD) SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names") IF(HAVE_FLAG_SEARCH_PATHS_FIRST) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-search_paths_first") + ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first") ENDIF() ENDIF() ELSE() @@ -893,7 +893,7 @@ MACRO(NL_SETUP_BUILD) IF(TARGET_ARMV7) ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -march=armv7-a -Wl,--fix-cortex-a8") + ADD_PLATFORM_LINKFLAGS("-march=armv7-a -Wl,--fix-cortex-a8") ELSEIF(TARGET_ARMV5) ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float") ENDIF() @@ -913,8 +913,8 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers") SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300") ENDIF() - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-z,noexecstack") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -L${PLATFORM_ROOT}/usr/lib") + ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack") + ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib") ENDIF() IF(APPLE) @@ -932,12 +932,12 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4") IF(NOT APPLE) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed") + ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed") ENDIF() IF(NOT APPLE) # hardening - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now") + ADD_PLATFORM_LINKFLAGS("-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now") ENDIF() IF(WITH_SYMBOLS) From e0cb4bbe9e1e9eea3edcebe1315d6fd8114c3161 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:35:55 +0100 Subject: [PATCH 2/9] Changed: Use NLMISC::openURL to open a page in browser --HG-- branch : develop --- .../leveldesign/georges_dll/georges_edit.cpp | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp index 1860096aa..effc20681 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp @@ -920,39 +920,7 @@ LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata) void CGeorgesEditApp::gotoURL (LPCTSTR url) { - char key[MAX_PATH + MAX_PATH]; - - // First try ShellExecute() - HINSTANCE result = ShellExecute(NULL, "open", url, NULL,NULL, SW_SHOW); - - // If it failed, get the .htm regkey and lookup the program - if ((UINT)result <= HINSTANCE_ERROR) { - - if (GetRegKey(HKEY_CLASSES_ROOT, ".htm", key) == ERROR_SUCCESS) - { - lstrcat(key, "\\shell\\open\\command"); - - if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) - { - char *pos; - pos = strstr(key, "\"%1\""); - if (pos == NULL) - { // No quotes found - pos = strstr(key, "%1"); // Check for %1, without quotes - if (pos == NULL) // No parameter at all... - pos = key+lstrlen(key)-1; - else - *pos = '\0'; // Remove the parameter - } - else - *pos = '\0'; // Remove the parameter - - lstrcat(pos, " "); - lstrcat(pos, url); - result = (HINSTANCE) WinExec(key, SW_SHOW); - } - } - } + NLMISC::openURL(tStrToUtf8(url)); } void CGeorgesEditApp::WinHelp(DWORD dwData, UINT nCmd) From 9bb46d2ae8f6096191d8fe0c78a8768da291cfd3 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:39:19 +0100 Subject: [PATCH 3/9] Fixed: Compilation with clang --HG-- branch : develop --- .../mac/{cocoa_opengl_view.m => cocoa_opengl_view.mm} | 0 code/nel/src/gui/interface_expr.cpp | 2 +- code/nel/src/misc/common.cpp | 6 +++--- code/nel/src/net/sock.cpp | 11 +++++++---- code/ryzom/client/src/login_patch.h | 1 + .../common/src/game_share/ring_session_manager_itf.h | 4 +--- code/ryzom/common/src/game_share/utils.h | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) rename code/nel/src/3d/driver/opengl/mac/{cocoa_opengl_view.m => cocoa_opengl_view.mm} (100%) diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.mm similarity index 100% rename from code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m rename to code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.mm diff --git a/code/nel/src/gui/interface_expr.cpp b/code/nel/src/gui/interface_expr.cpp index 9d13286a9..77d48906e 100644 --- a/code/nel/src/gui/interface_expr.cpp +++ b/code/nel/src/gui/interface_expr.cpp @@ -749,7 +749,7 @@ namespace NLGUI std::string str; for (;;) { - if (expr == '\0') + if (*expr == '\0') { nlwarning("CInterfaceExprValue::evalString : end of buffer encountered in a string"); return NULL; diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index ca116d0f8..3f39ab86a 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -1493,7 +1493,7 @@ static bool openDocWithExtension (const std::string &document, const std::string return true; } #elif defined(NL_OS_MAC) - CFURLRef url = CFURLCreateWithBytes(NULL, (const UInt8 *)document, strlen(document), kCFStringEncodingUTF8, NULL); + CFURLRef url = CFURLCreateWithBytes(NULL, (const UInt8 *)document.c_str(), document.length(), kCFStringEncodingUTF8, NULL); if (url) { @@ -1502,7 +1502,7 @@ static bool openDocWithExtension (const std::string &document, const std::string if (res != 0) { - nlwarning("LSOpenCFURLRef %s returned %d", document, (sint)res); + nlwarning("LSOpenCFURLRef %s returned %d", document.c_str(), (sint)res); return false; } @@ -1510,7 +1510,7 @@ static bool openDocWithExtension (const std::string &document, const std::string } else { - nlwarning("Unable to create URL from %s", document); + nlwarning("Unable to create URL from %s", document.c_str()); return false; } #else diff --git a/code/nel/src/net/sock.cpp b/code/nel/src/net/sock.cpp index 77c707712..4a6b57e95 100644 --- a/code/nel/src/net/sock.cpp +++ b/code/nel/src/net/sock.cpp @@ -497,9 +497,9 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except if ( _NonBlocking ) { // Receive incoming message (only the received part) - TTicks before = CTime::getPerformanceTime(); - len = ::recv( _Sock, (char*)buffer, len, 0 ); + + sint retLen = ::recv( _Sock, (char*)buffer, len, 0 ); //nlinfo ("CSock::receive(): NBM Received %d bytes to %d res: %d (%d)", realLen, _Sock, len, ERROR_NUM); @@ -509,7 +509,8 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except } _MaxReceiveTime = max( (uint32)(CTime::ticksToSecond(CTime::getPerformanceTime()-before)*1000.0f), _MaxReceiveTime ); - switch ( len ) + + switch (retLen) { // Graceful disconnection case 0 : @@ -546,12 +547,14 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except } } } + + len = (uint32)retLen; } else // Blocking Mode { // Receive incoming message, waiting until a complete message has arrived uint total = 0; - uint brecvd; + sint brecvd; while ( total < len ) { diff --git a/code/ryzom/client/src/login_patch.h b/code/ryzom/client/src/login_patch.h index 0daf83b46..2b108994d 100644 --- a/code/ryzom/client/src/login_patch.h +++ b/code/ryzom/client/src/login_patch.h @@ -34,6 +34,7 @@ class CPatchThread; class CCheckThread; class CScanDataThread; class CInstallThread; +class CDownloadThread; // Useful for using an external downloader (BitTorrent) use of interface with CGameDownloader from client_background_rd.exe using as install program diff --git a/code/ryzom/common/src/game_share/ring_session_manager_itf.h b/code/ryzom/common/src/game_share/ring_session_manager_itf.h index 7dc9d5af3..832903ad1 100644 --- a/code/ryzom/common/src/game_share/ring_session_manager_itf.h +++ b/code/ryzom/common/src/game_share/ring_session_manager_itf.h @@ -1666,12 +1666,11 @@ namespace RSMGR sf_shard28 = 1<<28, sf_shard29 = 1<<29, sf_shard30 = 1<<30, - sf_shard31 = 1<<31, invalid_val, /// Number of enumerated values - nb_enum_items = 32 + nb_enum_items = 31 }; @@ -1709,7 +1708,6 @@ namespace RSMGR NL_STRING_CONVERSION_TABLE_ENTRY(sf_shard28) NL_STRING_CONVERSION_TABLE_ENTRY(sf_shard29) NL_STRING_CONVERSION_TABLE_ENTRY(sf_shard30) - NL_STRING_CONVERSION_TABLE_ENTRY(sf_shard31) NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val) }; static NLMISC::CStringConversion diff --git a/code/ryzom/common/src/game_share/utils.h b/code/ryzom/common/src/game_share/utils.h index c4c0fe26f..2914f0dc8 100644 --- a/code/ryzom/common/src/game_share/utils.h +++ b/code/ryzom/common/src/game_share/utils.h @@ -76,7 +76,7 @@ inline ucstring capitalize(const ucstring & s) #define MACRO_CONCAT2(a,b) CONCAT(a,b) #define MACRO_TOTXT(a) #a #define MACRO_TOTXT2(a) TOTXT(a) -#define __FILE_LINE__ __FILE__ ":"TOTXT2(__LINE__)":" +#define __FILE_LINE__ __FILE__ ":" TOTXT2(__LINE__) ":" //------------------------------------------------------------------------------------------------- From a56b938636f10b06eab422e92d57553ed86389c4 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:40:24 +0100 Subject: [PATCH 4/9] Changed: Only compile with libc++ in C++ --HG-- branch : develop --- code/CMakeModules/nel.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 3aa9d66bc..874e44e0f 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -840,9 +840,9 @@ MACRO(NL_SETUP_BUILD) # use libc++ under OX X to be able to use new C++ features (and else it'll use GCC 4.2.1 STL) # minimum target is now OS X 10.7 - ADD_PLATFORM_FLAGS("-stdlib=libc++") - - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names") + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -stdlib=libc++") + + ADD_PLATFORM_LINKFLAGS("-Wl,-headerpad_max_install_names") IF(HAVE_FLAG_SEARCH_PATHS_FIRST) ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first") From bb9db58f0c51d7473c41067c23dc0887befe2cd6 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:40:48 +0100 Subject: [PATCH 5/9] Fixed: Only compile in c++0x in C++ --HG-- branch : develop --- code/CMakeModules/nel.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 874e44e0f..d347009f4 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -859,7 +859,7 @@ MACRO(NL_SETUP_BUILD) ENDIF() # use c++0x standard to use std::unique_ptr and std::shared_ptr - ADD_PLATFORM_FLAGS("-std=c++0x") + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -std=c++0x") ADD_PLATFORM_FLAGS("-D_REENTRANT") From 957bb8eeed4e55a0d23095afdc2be77da9f18976 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:42:11 +0100 Subject: [PATCH 6/9] Changed: Display all warnings excepted unused parameters --HG-- branch : develop --- code/CMakeModules/nel.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index d347009f4..dc728d868 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -875,12 +875,15 @@ MACRO(NL_SETUP_BUILD) ENDIF() IF(WITH_WARNINGS) - ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused") + ADD_PLATFORM_FLAGS("-Wall -W") ELSE() # Check wrong formats in printf-like functions ADD_PLATFORM_FLAGS("-Wformat -Werror=format-security") ENDIF() + # never display these warnings because they are minor + ADD_PLATFORM_FLAGS("-Wno-unused-parameter") + IF(ANDROID) ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}") ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables") From e008cd4dae7a57fcc0cec1544c79719c23a42b6a Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:42:21 +0100 Subject: [PATCH 7/9] Changed: Display if using Ninja --HG-- branch : develop --- code/CMakeModules/nel.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index dc728d868..b9967d386 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -433,6 +433,11 @@ MACRO(NL_SETUP_BUILD) MESSAGE(STATUS "Generating NMake project") ENDIF() + IF(CMAKE_GENERATOR MATCHES "Ninja") + SET(NINJA ON) + MESSAGE(STATUS "Generating Ninja project") + ENDIF() + # If target and host CPU are the same IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) # x86-compatible CPU From 0ae10c404e42cf6d872e75ffa6135d16e61ee4b5 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:52:14 +0100 Subject: [PATCH 8/9] Changed: Display more warnings if using -fstack-protector --HG-- branch : develop --- code/CMakeModules/nel.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index b9967d386..96b33c648 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -939,6 +939,14 @@ MACRO(NL_SETUP_BUILD) # hardening ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4") + # If -fstack-protector or -fstack-protector-all enabled, enable too new warnings and fix possible link problems + IF(WITH_WARNINGS) + ADD_PLATFORM_FLAGS("-Wstack-protector") + ENDIF() + + # Fix undefined reference to `__stack_chk_fail' error + ADD_PLATFORM_LINKFLAGS("-lc") + IF(NOT APPLE) ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed") ENDIF() From 0bc80be12437c065199c8de54a4abde566e5d2cb Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Dec 2016 19:52:25 +0100 Subject: [PATCH 9/9] Changed: Minor change --HG-- branch : develop --- code/CMakeModules/PCHSupport.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index f56626da1..36d031f10 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -305,8 +305,9 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS) ENDIF() IF(MSVC) - GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target}) - SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") + GET_PDB_FILENAME(_PDB_FILE ${_PCH_current_target}) + SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${_PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") + # Ninja PCH Support # http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj")