summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorBrad Linden <46733234+brad-linden@users.noreply.github.com>2024-06-12 14:33:01 -0700
committerGitHub <noreply@github.com>2024-06-12 14:33:01 -0700
commit071e464155a670a9a7e836ec52049fc80b507995 (patch)
treee129794d3f4c29c92d6515cbdbe6898ee8aa558b /indra/llcommon
parentf0de2ba6340e0d540aa70ac0086defde52cf60af (diff)
parent8444cd9562a6a7b755fcb075864e205122354192 (diff)
Merge pull request #1723 from secondlife/brad/maint-a-merge-to-gltf-dev
maint a merge to gltf dev
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/StackWalker.cpp66
-rw-r--r--indra/llcommon/is_approx_equal_fraction.h10
-rw-r--r--indra/llcommon/llalignedarray.h4
-rw-r--r--indra/llcommon/llapp.cpp12
-rw-r--r--indra/llcommon/llcoros.cpp14
-rw-r--r--indra/llcommon/llcoros.h14
-rw-r--r--indra/llcommon/lldefs.h154
-rw-r--r--indra/llcommon/llevents.cpp26
-rw-r--r--indra/llcommon/llfasttimer.h2
-rw-r--r--indra/llcommon/llfile.cpp14
-rw-r--r--indra/llcommon/llfile.h4
-rw-r--r--indra/llcommon/llfindlocale.cpp8
-rw-r--r--indra/llcommon/llindexedvector.h8
-rw-r--r--indra/llcommon/llleap.cpp2
-rw-r--r--indra/llcommon/llmainthreadtask.h2
-rw-r--r--indra/llcommon/llpreprocessor.h36
-rw-r--r--indra/llcommon/llqueuedthread.cpp2
-rw-r--r--indra/llcommon/llsdjson.cpp10
-rw-r--r--indra/llcommon/llsdjson.h22
-rw-r--r--indra/llcommon/llsdserialize.cpp8
-rw-r--r--indra/llcommon/llsingleton.h17
-rw-r--r--indra/llcommon/llstl.h2
-rw-r--r--indra/llcommon/llstreamqueue.h2
-rw-r--r--indra/llcommon/llstring.cpp12
-rw-r--r--indra/llcommon/llthread.h30
-rw-r--r--indra/llcommon/lltraceaccumulators.h6
-rw-r--r--indra/llcommon/lluuid.h2
-rw-r--r--indra/llcommon/tests/commonmisc_test.cpp6
-rw-r--r--indra/llcommon/tests/lleventdispatcher_test.cpp8
-rw-r--r--indra/llcommon/tests/llsdserialize_test.cpp18
-rw-r--r--indra/llcommon/threadpool.cpp2
31 files changed, 255 insertions, 268 deletions
diff --git a/indra/llcommon/StackWalker.cpp b/indra/llcommon/StackWalker.cpp
index 2c1bc47d0e..e9ae1723fb 100644
--- a/indra/llcommon/StackWalker.cpp
+++ b/indra/llcommon/StackWalker.cpp
@@ -1,5 +1,5 @@
/**********************************************************************
- *
+ *
* StackWalker.cpp
* http://stackwalker.codeplex.com/
*
@@ -13,14 +13,14 @@
* http://www.codeproject.com/threads/StackWalker.asp
* 2005-07-28 v2 - Changed the params of the constructor and ShowCallstack
* (to simplify the usage)
- * 2005-08-01 v3 - Changed to use 'CONTEXT_FULL' instead of CONTEXT_ALL
+ * 2005-08-01 v3 - Changed to use 'CONTEXT_FULL' instead of CONTEXT_ALL
* (should also be enough)
* - Changed to compile correctly with the PSDK of VC7.0
* (GetFileVersionInfoSizeA and GetFileVersionInfoA is wrongly defined:
* it uses LPSTR instead of LPCSTR as first paremeter)
* - Added declarations to support VC5/6 without using 'dbghelp.h'
- * - Added a 'pUserData' member to the ShowCallstack function and the
- * PReadProcessMemoryRoutine declaration (to pass some user-defined data,
+ * - Added a 'pUserData' member to the ShowCallstack function and the
+ * PReadProcessMemoryRoutine declaration (to pass some user-defined data,
* which can be used in the readMemoryFunction-callback)
* 2005-08-02 v4 - OnSymInit now also outputs the OS-Version by default
* - Added example for doing an exception-callstack-walking in main.cpp
@@ -60,26 +60,26 @@
* Copyright (c) 2005-2013, Jochen Kalmbach
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without modification,
+ * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of Jochen Kalmbach nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Jochen Kalmbach nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**********************************************************************/
@@ -234,7 +234,7 @@ DWORD64
// Some missing defines (for VC5/6):
#ifndef INVALID_FILE_ATTRIBUTES
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
-#endif
+#endif
// secure-CRT_functions are only available starting with VC8
@@ -396,7 +396,7 @@ public:
m_szSymPath = _strdup(szSymPath);
if (this->pSI(m_hProcess, m_szSymPath, FALSE) == FALSE)
this->m_parent->OnDbgHelpErr("SymInitialize", GetLastError(), 0);
-
+
DWORD symOptions = this->pSGO(); // SymGetOptions
symOptions |= SYMOPT_LOAD_LINES;
symOptions |= SYMOPT_FAIL_CRITICAL_ERRORS;
@@ -512,11 +512,11 @@ struct IMAGEHLP_MODULE64_V2 {
tSSO pSSO;
// StackWalk64()
- typedef BOOL (__stdcall *tSW)(
- DWORD MachineType,
+ typedef BOOL (__stdcall *tSW)(
+ DWORD MachineType,
HANDLE hProcess,
- HANDLE hThread,
- LPSTACKFRAME64 StackFrame,
+ HANDLE hThread,
+ LPSTACKFRAME64 StackFrame,
PVOID ContextRecord,
PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
@@ -1012,7 +1012,7 @@ bool StackWalker::LoadModules()
// The following is used to pass the "userData"-Pointer to the user-provided readMemoryFunction
// This has to be done due to a problem with the "hProcess"-parameter in x64...
-// Because this class is in no case multi-threading-enabled (because of the limitations
+// Because this class is in no case multi-threading-enabled (because of the limitations
// of dbghelp.dll) it is "safe" to use a static-variable
static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL;
static LPVOID s_readMemoryFunction_UserData = NULL;
@@ -1222,7 +1222,7 @@ bool StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *con
csEntry.symTypeString = NULL;
break;
}
-
+
MyStrCpy(csEntry.moduleName, STACKWALK_MAX_NAMELEN, Module.ModuleName);
csEntry.baseOfImage = Module.BaseOfImage;
MyStrCpy(csEntry.loadedImageName, STACKWALK_MAX_NAMELEN, Module.LoadedImageName);
@@ -1243,7 +1243,7 @@ bool StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *con
et = firstEntry;
bLastEntryCalled = false;
this->OnCallstackEntry(et, csEntry);
-
+
if (s.AddrReturn.Offset == 0)
{
bLastEntryCalled = true;
@@ -1358,7 +1358,7 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
ver.dwOSVersionInfoSize = sizeof(ver);
if (GetVersionExA(&ver) != FALSE)
{
- _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "OS-Version: %d.%d.%d (%s)\n",
+ _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "OS-Version: %d.%d.%d (%s)\n",
ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber,
ver.szCSDVersion);
if (m_verbose)
@@ -1372,7 +1372,7 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
ver.dwOSVersionInfoSize = sizeof(ver);
if (GetVersionExA( (OSVERSIONINFOA*) &ver) != FALSE)
{
- _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "OS-Version: %d.%d.%d (%s) 0x%x-0x%x\n",
+ _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "OS-Version: %d.%d.%d (%s) 0x%x-0x%x\n",
ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber,
ver.szCSDVersion, ver.wSuiteMask, ver.wProductType);
if (m_verbose)
diff --git a/indra/llcommon/is_approx_equal_fraction.h b/indra/llcommon/is_approx_equal_fraction.h
index 732d168986..371a1307c1 100644
--- a/indra/llcommon/is_approx_equal_fraction.h
+++ b/indra/llcommon/is_approx_equal_fraction.h
@@ -5,25 +5,25 @@
* @brief lltut.h uses is_approx_equal_fraction(). Moved to this header
* file in llcommon so we can use lltut.h for llcommon tests without
* making llcommon depend on llmath.
- *
+ *
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
diff --git a/indra/llcommon/llalignedarray.h b/indra/llcommon/llalignedarray.h
index 0ba8b34cb6..8248f82186 100644
--- a/indra/llcommon/llalignedarray.h
+++ b/indra/llcommon/llalignedarray.h
@@ -116,7 +116,7 @@ void LLAlignedArray<T, alignment>::resize(U32 size)
template <class T, U32 alignment>
T& LLAlignedArray<T, alignment>::operator[](int idx)
{
- if(idx >= mElementCount || idx < 0)
+ if (idx < 0 || unsigned(idx) >= mElementCount)
{
LL_ERRS() << "Out of bounds LLAlignedArray, requested: " << (S32)idx << " size: " << mElementCount << LL_ENDL;
}
@@ -126,7 +126,7 @@ T& LLAlignedArray<T, alignment>::operator[](int idx)
template <class T, U32 alignment>
const T& LLAlignedArray<T, alignment>::operator[](int idx) const
{
- if (idx >= mElementCount || idx < 0)
+ if (idx < 0 || unsigned(idx) >= mElementCount)
{
LL_ERRS() << "Out of bounds LLAlignedArray, requested: " << (S32)idx << " size: " << mElementCount << LL_ENDL;
}
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index 64497df875..b85bd2573b 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -199,9 +199,9 @@ bool LLApp::parseCommandOptions(int argc, char** argv)
#if LL_WINDOWS
//Windows changed command line parsing. Deal with it.
- S32 slen = value.length() - 1;
- S32 start = 0;
- S32 end = slen;
+ size_t slen = value.length() - 1;
+ size_t start = 0;
+ size_t end = slen;
if (argv[ii][start]=='"')start++;
if (argv[ii][end]=='"')end--;
if (start!=0 || end!=slen)
@@ -264,9 +264,9 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)
#if LL_WINDOWS
//Windows changed command line parsing. Deal with it.
- S32 slen = value.length() - 1;
- S32 start = 0;
- S32 end = slen;
+ size_t slen = value.length() - 1;
+ size_t start = 0;
+ size_t end = slen;
if (wargv[ii][start]=='"')start++;
if (wargv[ii][end]=='"')end--;
if (start!=0 || end!=slen)
diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp
index 23b30bcc57..1539b48bd3 100644
--- a/indra/llcommon/llcoros.cpp
+++ b/indra/llcommon/llcoros.cpp
@@ -3,25 +3,25 @@
* @author Nat Goodspeed
* @date 2009-06-03
* @brief Implementation for llcoros.
- *
+ *
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -61,14 +61,14 @@
#include <excpt.h>
#endif
-// static
+// static
bool LLCoros::on_main_coro()
{
if (!LLCoros::instanceExists() || LLCoros::getName().empty())
{
return true;
}
-
+
return false;
}
diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h
index 00650a2454..369d65407e 100644
--- a/indra/llcommon/llcoros.h
+++ b/indra/llcommon/llcoros.h
@@ -3,25 +3,25 @@
* @author Nat Goodspeed
* @date 2009-06-02
* @brief Manage running boost::coroutine instances
- *
+ *
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -100,7 +100,7 @@ public:
static bool on_main_coro();
// For debugging, return true if on the main thread and not in a coroutine
- // Non-thread-safe code in the main loop should be protected by
+ // Non-thread-safe code in the main loop should be protected by
// llassert(LLCoros::on_main_thread_main_coro())
static bool on_main_thread_main_coro();
@@ -168,7 +168,7 @@ public:
* LLCoros::launch()).
*/
static std::string getName();
-
+
/**
* rethrow() is called by the thread's main fiber to propagate an
* exception from any coroutine into the main fiber, where it can engage
diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h
index 0ba756d472..2fbb26dc1a 100644
--- a/indra/llcommon/lldefs.h
+++ b/indra/llcommon/lldefs.h
@@ -31,64 +31,64 @@
#include <type_traits>
// Often used array indices
-const U32 VX = 0;
-const U32 VY = 1;
-const U32 VZ = 2;
-const U32 VW = 3;
-const U32 VS = 3;
-
-const U32 VRED = 0;
-const U32 VGREEN = 1;
-const U32 VBLUE = 2;
-const U32 VALPHA = 3;
-
-const U32 INVALID_DIRECTION = 0xFFFFFFFF;
-const U32 EAST = 0;
-const U32 NORTH = 1;
-const U32 WEST = 2;
-const U32 SOUTH = 3;
-
-const U32 NORTHEAST = 4;
-const U32 NORTHWEST = 5;
-const U32 SOUTHWEST = 6;
-const U32 SOUTHEAST = 7;
-const U32 MIDDLE = 8;
-
-const U8 EAST_MASK = 0x1<<EAST;
-const U8 NORTH_MASK = 0x1<<NORTH;
-const U8 WEST_MASK = 0x1<<WEST;
-const U8 SOUTH_MASK = 0x1<<SOUTH;
-
-const U8 NORTHEAST_MASK = NORTH_MASK | EAST_MASK;
-const U8 NORTHWEST_MASK = NORTH_MASK | WEST_MASK;
-const U8 SOUTHWEST_MASK = SOUTH_MASK | WEST_MASK;
-const U8 SOUTHEAST_MASK = SOUTH_MASK | EAST_MASK;
-
-const U32 gDirOpposite[8] = {2, 3, 0, 1, 6, 7, 4, 5};
-const U32 gDirAdjacent[8][2] = {
- {4, 7},
- {4, 5},
- {5, 6},
- {6, 7},
- {0, 1},
- {1, 2},
- {2, 3},
- {0, 3}
- };
+constexpr U32 VX = 0;
+constexpr U32 VY = 1;
+constexpr U32 VZ = 2;
+constexpr U32 VW = 3;
+constexpr U32 VS = 3;
+
+constexpr U32 VRED = 0;
+constexpr U32 VGREEN = 1;
+constexpr U32 VBLUE = 2;
+constexpr U32 VALPHA = 3;
+
+constexpr U32 INVALID_DIRECTION = 0xFFFFFFFF;
+constexpr U32 EAST = 0;
+constexpr U32 NORTH = 1;
+constexpr U32 WEST = 2;
+constexpr U32 SOUTH = 3;
+
+constexpr U32 NORTHEAST = 4;
+constexpr U32 NORTHWEST = 5;
+constexpr U32 SOUTHWEST = 6;
+constexpr U32 SOUTHEAST = 7;
+constexpr U32 MIDDLE = 8;
+
+constexpr U8 EAST_MASK = 0x1<<EAST;
+constexpr U8 NORTH_MASK = 0x1<<NORTH;
+constexpr U8 WEST_MASK = 0x1<<WEST;
+constexpr U8 SOUTH_MASK = 0x1<<SOUTH;
+
+constexpr U8 NORTHEAST_MASK = NORTH_MASK | EAST_MASK;
+constexpr U8 NORTHWEST_MASK = NORTH_MASK | WEST_MASK;
+constexpr U8 SOUTHWEST_MASK = SOUTH_MASK | WEST_MASK;
+constexpr U8 SOUTHEAST_MASK = SOUTH_MASK | EAST_MASK;
+
+constexpr U32 gDirOpposite[8] = {2, 3, 0, 1, 6, 7, 4, 5};
+constexpr U32 gDirAdjacent[8][2] = {
+ {4, 7},
+ {4, 5},
+ {5, 6},
+ {6, 7},
+ {0, 1},
+ {1, 2},
+ {2, 3},
+ {0, 3}
+ };
// Magnitude along the x and y axis
-const S32 gDirAxes[8][2] = {
- { 1, 0}, // east
- { 0, 1}, // north
- {-1, 0}, // west
- { 0,-1}, // south
- { 1, 1}, // ne
- {-1, 1}, // nw
- {-1,-1}, // sw
- { 1,-1}, // se
- };
-
-const S32 gDirMasks[8] = {
+constexpr S32 gDirAxes[8][2] = {
+ { 1, 0}, // east
+ { 0, 1}, // north
+ {-1, 0}, // west
+ { 0,-1}, // south
+ { 1, 1}, // ne
+ {-1, 1}, // nw
+ {-1,-1}, // sw
+ { 1,-1}, // se
+ };
+
+constexpr S32 gDirMasks[8] = {
EAST_MASK,
NORTH_MASK,
WEST_MASK,
@@ -117,22 +117,22 @@ const S32 gDirMasks[8] = {
// | / -6- | /
// |/ / |/
// +------------------+
-const U32 NO_SIDE = 0;
-const U32 FRONT_SIDE = 1;
-const U32 BACK_SIDE = 2;
-const U32 LEFT_SIDE = 3;
-const U32 RIGHT_SIDE = 4;
-const U32 TOP_SIDE = 5;
-const U32 BOTTOM_SIDE = 6;
-
-const U8 LL_SOUND_FLAG_NONE = 0x0;
-const U8 LL_SOUND_FLAG_LOOP = 1<<0;
-const U8 LL_SOUND_FLAG_SYNC_MASTER = 1<<1;
-const U8 LL_SOUND_FLAG_SYNC_SLAVE = 1<<2;
-const U8 LL_SOUND_FLAG_SYNC_PENDING = 1<<3;
-const U8 LL_SOUND_FLAG_QUEUE = 1<<4;
-const U8 LL_SOUND_FLAG_STOP = 1<<5;
-const U8 LL_SOUND_FLAG_SYNC_MASK = LL_SOUND_FLAG_SYNC_MASTER | LL_SOUND_FLAG_SYNC_SLAVE | LL_SOUND_FLAG_SYNC_PENDING;
+constexpr U32 NO_SIDE = 0;
+constexpr U32 FRONT_SIDE = 1;
+constexpr U32 BACK_SIDE = 2;
+constexpr U32 LEFT_SIDE = 3;
+constexpr U32 RIGHT_SIDE = 4;
+constexpr U32 TOP_SIDE = 5;
+constexpr U32 BOTTOM_SIDE = 6;
+
+constexpr U8 LL_SOUND_FLAG_NONE = 0x0;
+constexpr U8 LL_SOUND_FLAG_LOOP = 1<<0;
+constexpr U8 LL_SOUND_FLAG_SYNC_MASTER = 1<<1;
+constexpr U8 LL_SOUND_FLAG_SYNC_SLAVE = 1<<2;
+constexpr U8 LL_SOUND_FLAG_SYNC_PENDING = 1<<3;
+constexpr U8 LL_SOUND_FLAG_QUEUE = 1<<4;
+constexpr U8 LL_SOUND_FLAG_STOP = 1<<5;
+constexpr U8 LL_SOUND_FLAG_SYNC_MASK = LL_SOUND_FLAG_SYNC_MASTER | LL_SOUND_FLAG_SYNC_SLAVE | LL_SOUND_FLAG_SYNC_PENDING;
//
// *NOTE: These values may be used as hard-coded numbers in scanf() variants.
@@ -141,17 +141,17 @@ const U8 LL_SOUND_FLAG_SYNC_MASK = LL_SOUND_FLAG_SYNC_MASTER | LL_SOUND_FLAG_SYN
// DO NOT CHANGE.
// --------------
//
-const U32 LL_MAX_PATH = 1024; // buffer size of maximum path + filename string length
+constexpr U32 LL_MAX_PATH = 1024; // buffer size of maximum path + filename string length
// For strings we send in messages
-const U32 STD_STRING_BUF_SIZE = 255; // Buffer size
-const U32 STD_STRING_STR_LEN = 254; // Length of the string (not including \0)
+constexpr U32 STD_STRING_BUF_SIZE = 255; // Buffer size
+constexpr U32 STD_STRING_STR_LEN = 254; // Length of the string (not including \0)
// *NOTE: This value is used as hard-coded numbers in scanf() variants.
// DO NOT CHANGE.
-const U32 MAX_STRING = STD_STRING_BUF_SIZE; // Buffer size
+constexpr U32 MAX_STRING = STD_STRING_BUF_SIZE; // Buffer size
-const U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 + 1 for good luck
+constexpr U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 + 1 for good luck
// C++ is our friend. . . use template functions to make life easier!
diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp
index 8006f9d059..3c6743eac9 100644
--- a/indra/llcommon/llevents.cpp
+++ b/indra/llcommon/llevents.cpp
@@ -3,25 +3,25 @@
* @author Nat Goodspeed
* @date 2008-09-12
* @brief Implementation for llevents.
- *
+ *
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -423,8 +423,8 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL
float nodePosition = 1.0;
- // if the supplied name is empty we are not interested in the ordering mechanism
- // and can bypass attempting to find the optimal location to insert the new
+ // if the supplied name is empty we are not interested in the ordering mechanism
+ // and can bypass attempting to find the optimal location to insert the new
// listener. We'll just tack it on to the end.
if (!name.empty()) // should be the same as testing against ANONYMOUS
{
@@ -569,12 +569,12 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL
// Now that newNode has a value that places it appropriately in mSignal,
// connect it.
LLBoundListener bound = mSignal->connect(nodePosition, listener);
-
+
if (!name.empty())
{ // note that we are not tracking anonymous listeners here either.
- // This means that it is the caller's responsibility to either assign
- // to a TempBoundListerer (scoped_connection) or manually disconnect
- // when done.
+ // This means that it is the caller's responsibility to either assign
+ // to a TempBoundListerer (scoped_connection) or manually disconnect
+ // when done.
mConnections[name] = bound;
}
return bound;
@@ -641,9 +641,9 @@ bool LLEventMailDrop::post(const LLSD& event)
{
// forward the call to our base class
bool posted = LLEventStream::post(event);
-
+
if (!posted)
- { // if the event was not handled we will save it for later so that it can
+ { // if the event was not handled we will save it for later so that it can
// be posted to any future listeners when they attach.
mEventHistory.push_back(event);
}
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 17ad37b031..09fcf8a1af 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -215,7 +215,7 @@ private:
private:
U64 mStartTime;
- BlockTimerStackRecord mParentTimerData;
+ BlockTimerStackRecord mParentTimerData{};
public:
// statics
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index 1877dd54ed..ddf239f306 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -27,6 +27,12 @@
* $/LicenseInfo$
*/
+#include "linden_common.h"
+#include "llfile.h"
+#include "llstring.h"
+#include "llerror.h"
+#include "stringize.h"
+
#if LL_WINDOWS
#include "llwin32headerslean.h"
#include <stdlib.h> // Windows errno
@@ -35,12 +41,6 @@
#include <errno.h>
#endif
-#include "linden_common.h"
-#include "llfile.h"
-#include "llstring.h"
-#include "llerror.h"
-#include "stringize.h"
-
using namespace std;
static std::string empty;
@@ -345,7 +345,7 @@ const char *LLFile::tmpdir()
sep = '\\';
std::vector<wchar_t> utf16path(MAX_PATH + 1);
- GetTempPathW(utf16path.size(), &utf16path[0]);
+ GetTempPathW(static_cast<DWORD>(utf16path.size()), &utf16path[0]);
utf8path = ll_convert_wide_to_string(&utf16path[0]);
#else
sep = '/';
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index 08a008c19a..2564671b13 100644
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -97,7 +97,7 @@ public:
// no copy
LLUniqueFile(const LLUniqueFile&) = delete;
// move construction
- LLUniqueFile(LLUniqueFile&& other)
+ LLUniqueFile(LLUniqueFile&& other) noexcept
{
mFileHandle = other.mFileHandle;
other.mFileHandle = nullptr;
@@ -118,7 +118,7 @@ public:
// copy assignment deleted
LLUniqueFile& operator=(const LLUniqueFile&) = delete;
// move assignment
- LLUniqueFile& operator=(LLUniqueFile&& other)
+ LLUniqueFile& operator=(LLUniqueFile&& other) noexcept
{
close();
std::swap(mFileHandle, other.mFileHandle);
diff --git a/indra/llcommon/llfindlocale.cpp b/indra/llcommon/llfindlocale.cpp
index e39812bfc4..ac52f90c9f 100644
--- a/indra/llcommon/llfindlocale.cpp
+++ b/indra/llcommon/llfindlocale.cpp
@@ -157,14 +157,22 @@ canonise_fl(FL_Locale *l) {
if (l->lang && 0 == strcmp(l->lang, "en")) {
if (l->country && 0 == strcmp(l->country, "UK")) {
free((void*)l->country);
+#ifdef LL_WINDOWS
+ l->country = _strdup("GB");
+#else
l->country = strdup("GB");
+#endif
}
}
/* ja_JA -> ja_JP */
if (l->lang && 0 == strcmp(l->lang, "ja")) {
if (l->country && 0 == strcmp(l->country, "JA")) {
free((void*)l->country);
+#ifdef LL_WINDOWS
+ l->country = _strdup("JP");
+#else
l->country = strdup("JP");
+#endif
}
}
}
diff --git a/indra/llcommon/llindexedvector.h b/indra/llcommon/llindexedvector.h
index de3ae0dcc4..0b2e9c76ca 100644
--- a/indra/llcommon/llindexedvector.h
+++ b/indra/llcommon/llindexedvector.h
@@ -47,7 +47,7 @@ public:
typedef typename std::vector<Type>::size_type size_type;
protected:
std::vector<Type> mVector;
- std::map<Key, U32> mIndexMap;
+ std::map<Key, size_t> mIndexMap;
public:
LLIndexedVector() { mVector.reserve(BlockSize); }
@@ -68,10 +68,10 @@ public:
Type& operator[](const Key& k)
{
- typename std::map<Key, U32>::const_iterator iter = mIndexMap.find(k);
+ typename std::map<Key, size_t>::const_iterator iter = mIndexMap.find(k);
if (iter == mIndexMap.end())
{
- U32 n = mVector.size();
+ auto n = mVector.size();
mIndexMap[k] = n;
mVector.push_back(Type());
llassert(mVector.size() == mIndexMap.size());
@@ -85,7 +85,7 @@ public:
const_iterator find(const Key& k) const
{
- typename std::map<Key, U32>::const_iterator iter = mIndexMap.find(k);
+ typename std::map<Key, size_t>::const_iterator iter = mIndexMap.find(k);
if(iter == mIndexMap.end())
{
return mVector.end();
diff --git a/indra/llcommon/llleap.cpp b/indra/llcommon/llleap.cpp
index e93ba83434..662a2511cd 100644
--- a/indra/llcommon/llleap.cpp
+++ b/indra/llcommon/llleap.cpp
@@ -233,7 +233,7 @@ public:
LL_DEBUGS("EventHost") << "Sending: "
<< static_cast<U64>(buffer.tellp()) << ':';
- std::string::size_type truncate(80);
+ llssize truncate(80);
if (buffer.tellp() <= truncate)
{
LL_CONT << buffer.str();
diff --git a/indra/llcommon/llmainthreadtask.h b/indra/llcommon/llmainthreadtask.h
index 5fae0212c4..cec95b2356 100644
--- a/indra/llcommon/llmainthreadtask.h
+++ b/indra/llcommon/llmainthreadtask.h
@@ -4,7 +4,7 @@
* @date 2019-12-04
* @brief LLMainThreadTask dispatches work to the main thread. When invoked on
* the main thread, it performs the work inline.
- *
+ *
* $LicenseInfo:firstyear=2019&license=viewerlgpl$
* Copyright (c) 2019, Linden Research, Inc.
* $/LicenseInfo$
diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h
index a54408a852..0248e8f8b9 100644
--- a/indra/llcommon/llpreprocessor.h
+++ b/indra/llcommon/llpreprocessor.h
@@ -120,44 +120,20 @@
#endif // LL_WINDOWS
-// Deal with VC6 problems
+// Deal with VC++ problems
#if LL_MSVC
-#pragma warning( 3 : 4701 ) // "local variable used without being initialized" Treat this as level 3, not level 4.
-#pragma warning( 3 : 4702 ) // "unreachable code" Treat this as level 3, not level 4.
-#pragma warning( 3 : 4189 ) // "local variable initialized but not referenced" Treat this as level 3, not level 4.
-//#pragma warning( 3 : 4018 ) // "signed/unsigned mismatch" Treat this as level 3, not level 4.
-#pragma warning( 3 : 4263 ) // 'function' : member function does not override any base class virtual member function
-#pragma warning( 3 : 4264 ) // "'virtual_function' : no override available for virtual member function from base 'class'; function is hidden"
-#pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual"
-#pragma warning( 3 : 4266 ) // 'function' : no override available for virtual member function from base 'type'; function is hidden
-#pragma warning (disable : 4180) // qualifier applied to function type has no meaning; ignored
-//#pragma warning( disable : 4284 ) // silly MS warning deep inside their <map> include file
-
-#if ADDRESS_SIZE == 64
-// That one is all over the place for x64 builds.
-#pragma warning( disable : 4267 ) // 'var' : conversion from 'size_t' to 'type', possible loss of data)
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS // disable warnings for methods considered unsafe
+#endif
+#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
+#define _WINSOCK_DEPRECATED_NO_WARNINGS // disable deprecated WinSock API warnings
#endif
-
-#pragma warning( disable : 4503 ) // 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation.
-#pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
-#pragma warning( disable : 4996 ) // warning: deprecated
-
-// Linker optimization with "extern template" generates these warnings
-#pragma warning( disable : 4231 ) // nonstandard extension used : 'extern' before template explicit instantiation
-#pragma warning( disable : 4506 ) // no definition for inline function
// level 4 warnings that we need to disable:
-#pragma warning (disable : 4100) // unreferenced formal parameter
-#pragma warning (disable : 4127) // conditional expression is constant (e.g. while(1) )
#pragma warning (disable : 4244) // possible loss of data on conversions
#pragma warning (disable : 4396) // the inline specifier cannot be used when a friend declaration refers to a specialization of a function template
-#pragma warning (disable : 4512) // assignment operator could not be generated
-#pragma warning (disable : 4706) // assignment within conditional (even if((x = y)) )
-
#pragma warning (disable : 4251) // member needs to have dll-interface to be used by clients of class
#pragma warning (disable : 4275) // non dll-interface class used as base for dll-interface class
-#pragma warning (disable : 4018) // '<' : signed/unsigned mismatch
-
#endif // LL_MSVC
#if LL_WINDOWS
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 39e8113587..7d77f6f6a9 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -210,7 +210,7 @@ void LLQueuedThread::waitOnPending()
// MAIN thread
void LLQueuedThread::printQueueStats()
{
- U32 size = mRequestQueue.size();
+ auto size = mRequestQueue.size();
if (size > 0)
{
LL_INFOS() << llformat("Pending Requests:%d ", mRequestQueue.size()) << LL_ENDL;
diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp
index 2fe24693dd..e95d2e6c1c 100644
--- a/indra/llcommon/llsdjson.cpp
+++ b/indra/llcommon/llsdjson.cpp
@@ -1,25 +1,25 @@
-/**
+/**
* @file llsdjson.cpp
* @brief LLSD flexible data system
*
* $LicenseInfo:firstyear=2015&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2015, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
diff --git a/indra/llcommon/llsdjson.h b/indra/llcommon/llsdjson.h
index 7173e26046..415bbf4821 100644
--- a/indra/llcommon/llsdjson.h
+++ b/indra/llcommon/llsdjson.h
@@ -1,25 +1,25 @@
-/**
+/**
* @file llsdjson.cpp
* @brief LLSD flexible data system
*
* $LicenseInfo:firstyear=2015&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2015, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -36,10 +36,10 @@
#include "llsd.h"
#include <boost/json.hpp>
-/// Convert a parsed JSON structure into LLSD maintaining member names and
+/// Convert a parsed JSON structure into LLSD maintaining member names and
/// array indexes.
/// JSON/JavaScript types are converted as follows:
-///
+///
/// JSON Type | LLSD Type
/// --------------+--------------
/// null | undefined
@@ -50,14 +50,14 @@
/// boolean | LLSD::Boolean
/// array | LLSD::Array
/// object | LLSD::Map
-///
+///
/// For maps and arrays child entries will be converted and added to the structure.
/// Order is preserved for an array but not for objects.
LLSD LlsdFromJson(const boost::json::value &val);
-/// Convert an LLSD object into Parsed JSON object maintaining member names and
+/// Convert an LLSD object into Parsed JSON object maintaining member names and
/// array indexs.
-///
+///
/// Types are converted as follows:
/// LLSD Type | JSON Type
/// --------------+----------------
@@ -71,7 +71,7 @@ LLSD LlsdFromJson(const boost::json::value &val);
/// TypeUUID | string
/// TypeMap | object
/// TypeArray | array
-/// TypeBinary | unsupported
+/// TypeBinary | unsupported
boost::json::value LlsdToJson(const LLSD &val);
#endif // LL_LLSDJSON_H
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index 92d9392477..15002580c9 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -1546,7 +1546,7 @@ S32 LLSDBinaryFormatter::format_impl(const LLSD& data, std::ostream& ostr,
case LLSD::TypeMap:
{
ostr.put('{');
- U32 size_nbo = htonl(data.size());
+ U32 size_nbo = htonl(static_cast<u_long>(data.size()));
ostr.write((const char*)(&size_nbo), sizeof(U32));
LLSD::map_const_iterator iter = data.beginMap();
LLSD::map_const_iterator end = data.endMap();
@@ -1563,7 +1563,7 @@ S32 LLSDBinaryFormatter::format_impl(const LLSD& data, std::ostream& ostr,
case LLSD::TypeArray:
{
ostr.put('[');
- U32 size_nbo = htonl(data.size());
+ U32 size_nbo = htonl(static_cast<u_long>(data.size()));
ostr.write((const char*)(&size_nbo), sizeof(U32));
LLSD::array_const_iterator iter = data.beginArray();
LLSD::array_const_iterator end = data.endArray();
@@ -1630,7 +1630,7 @@ S32 LLSDBinaryFormatter::format_impl(const LLSD& data, std::ostream& ostr,
{
ostr.put('b');
const std::vector<U8>& buffer = data.asBinary();
- U32 size_nbo = htonl(buffer.size());
+ U32 size_nbo = htonl(static_cast<u_long>(buffer.size()));
ostr.write((const char*)(&size_nbo), sizeof(U32));
if(buffer.size()) ostr.write((const char*)&buffer[0], buffer.size());
break;
@@ -1648,7 +1648,7 @@ void LLSDBinaryFormatter::formatString(
const std::string& string,
std::ostream& ostr) const
{
- U32 size_nbo = htonl(string.size());
+ U32 size_nbo = htonl(static_cast<u_long>(string.size()));
ostr.write((const char*)(&size_nbo), sizeof(U32));
ostr.write(string.c_str(), string.size());
}
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 61f82a4c03..7c6be25309 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -1,24 +1,24 @@
-/**
+/**
* @file llsingleton.h
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -36,6 +36,10 @@
#include "llthread.h" // on_main_thread()
#include "llmainthreadtask.h"
+#ifdef LL_WINDOWS
+#pragma warning( disable : 4506 ) // no definition for inline function
+#endif
+
class LLSingletonBase: private boost::noncopyable
{
public:
@@ -528,6 +532,7 @@ public:
classname<DERIVED_TYPE>(),
" -- creating new instance"});
// fall through
+ [[fallthrough]];
case UNINITIALIZED:
case QUEUED:
// QUEUED means some secondary thread has already requested an
@@ -826,7 +831,7 @@ private: \
// Relatively unsafe singleton implementation that is much faster
// and simpler than LLSingleton, but has no dependency tracking
-// or inherent thread safety and requires manual invocation of
+// or inherent thread safety and requires manual invocation of
// createInstance before first use.
template<class T>
class LLSimpleton
diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h
index 67b4c141af..1b52d94258 100644
--- a/indra/llcommon/llstl.h
+++ b/indra/llcommon/llstl.h
@@ -326,7 +326,7 @@ inline bool vector_replace_with_last(std::vector<T>& invec, const T& val)
template <typename T>
inline T* vector_append(std::vector<T>& invec, S32 N)
{
- U32 sz = invec.size();
+ auto sz = invec.size();
invec.resize(sz+N);
return &(invec[sz]);
}
diff --git a/indra/llcommon/llstreamqueue.h b/indra/llcommon/llstreamqueue.h
index a09bf4cb4b..01689457dd 100644
--- a/indra/llcommon/llstreamqueue.h
+++ b/indra/llcommon/llstreamqueue.h
@@ -216,7 +216,7 @@ std::streamsize LLGenericStreamQueue<Ch>::skip(std::streamsize n)
{
typename BufferList::iterator bli(mBuffer.begin()), blend(mBuffer.end());
std::streamsize toskip(n), skipped(0);
- while (bli != blend && toskip >= bli->length())
+ while (bli != blend && (size_t)toskip >= bli->length())
{
std::streamsize chunk(bli->length());
typename BufferList::iterator zap(bli++);
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 5df0f8702d..514d73b24b 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -809,7 +809,7 @@ std::string ll_convert_wide_to_string(const wchar_t* in, size_t len_in, unsigned
code_page,
0,
in,
- len_in,
+ static_cast<int>(len_in),
NULL,
0,
0,
@@ -824,7 +824,7 @@ std::string ll_convert_wide_to_string(const wchar_t* in, size_t len_in, unsigned
code_page,
0,
in,
- len_in,
+ static_cast<int>(len_in),
pout,
len_out,
0,
@@ -851,8 +851,8 @@ std::wstring ll_convert_string_to_wide(const char* in, size_t len, unsigned int
std::vector<wchar_t> w_out(len + 1);
memset(&w_out[0], 0, w_out.size());
- int real_output_str_len = MultiByteToWideChar(code_page, 0, in, len,
- &w_out[0], w_out.size() - 1);
+ int real_output_str_len = MultiByteToWideChar(code_page, 0, in, static_cast<int>(len),
+ &w_out[0], static_cast<int>(w_out.size() - 1));
//looks like MultiByteToWideChar didn't add null terminator to converted string, see EXT-4858.
w_out[real_output_str_len] = 0;
@@ -943,7 +943,7 @@ std::optional<std::wstring> llstring_getoptenv(const std::string& key)
auto wkey = ll_convert_string_to_wide(key);
// Take a wild guess as to how big the buffer should be.
std::vector<wchar_t> buffer(1024);
- auto n = GetEnvironmentVariableW(wkey.c_str(), &buffer[0], buffer.size());
+ auto n = GetEnvironmentVariableW(wkey.c_str(), &buffer[0], static_cast<DWORD>(buffer.size()));
// If our initial guess was too short, n will indicate the size (in
// wchar_t's) that buffer should have been, including the terminating nul.
if (n > (buffer.size() - 1))
@@ -951,7 +951,7 @@ std::optional<std::wstring> llstring_getoptenv(const std::string& key)
// make it big enough
buffer.resize(n);
// and try again
- n = GetEnvironmentVariableW(wkey.c_str(), &buffer[0], buffer.size());
+ n = GetEnvironmentVariableW(wkey.c_str(), &buffer[0], static_cast<DWORD>(buffer.size()));
}
// did that (ultimately) succeed?
if (n)
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index cf2ae00cd7..4194e0014d 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -1,25 +1,25 @@
-/**
+/**
* @file llthread.h
* @brief Base classes for thread, mutex and condition handling.
*
* $LicenseInfo:firstyear=2004&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010-2013, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -55,10 +55,10 @@ public:
LLThread(const std::string& name, apr_pool_t *poolp = NULL);
virtual ~LLThread(); // Warning! You almost NEVER want to destroy a thread unless it's in the STOPPED state.
virtual void shutdown(); // stops the thread
-
+
bool isQuitting() const { return (QUITTING == mStatus); }
bool isStopped() const { return (STOPPED == mStatus) || (CRASHED == mStatus); }
- bool isCrashed() const { return (CRASHED == mStatus); }
+ bool isCrashed() const { return (CRASHED == mStatus); }
static id_t currentID(); // Return ID of current thread
static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure.
@@ -90,11 +90,11 @@ public:
// internal state used by LLMutex. You must call this once early
// in the running thread to prevent collisions with the main thread.
static void registerThreadID();
-
+
private:
bool mPaused;
std::thread::native_handle_type mNativeHandle; // for termination in case of issues
-
+
// static function passed to APR thread creation routine
void threadRun();
@@ -111,21 +111,21 @@ protected:
//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
// otherwise it will cause severe memory leaking!!! --bao
- LLVolatileAPRPool *mLocalAPRFilePoolp ;
+ LLVolatileAPRPool *mLocalAPRFilePoolp ;
void setQuitting();
-
+
// virtual function overridden by subclass -- this will be called when the thread runs
- virtual void run(void) = 0;
-
+ virtual void run(void) = 0;
+
// virtual predicate function -- returns true if the thread should wake up, false if it should sleep.
virtual bool runCondition(void);
// Lock/Unlock Run Condition -- use around modification of any variable used in runCondition()
void lockData();
void unlockData();
-
- // This is the predicate that decides whether the thread should sleep.
+
+ // This is the predicate that decides whether the thread should sleep.
// It should only be called with mDataLock locked, since the virtual runCondition() function may need to access
// data structures that are thread-unsafe.
bool shouldSleep(void) { return (mStatus == RUNNING) && (isPaused() || (!runCondition())); }
diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h
index 692bbe5acf..ba7acf9547 100644
--- a/indra/llcommon/lltraceaccumulators.h
+++ b/indra/llcommon/lltraceaccumulators.h
@@ -522,9 +522,9 @@ namespace LLTrace
struct BlockTimerStackRecord
{
- class BlockTimer* mActiveTimer;
- class BlockTimerStatHandle* mTimeBlock;
- U64 mChildTime;
+ class BlockTimer* mActiveTimer{ nullptr };
+ class BlockTimerStatHandle* mTimeBlock{ nullptr };
+ U64 mChildTime{ 0 };
};
struct AccumulatorBufferGroup : public LLRefCount
diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h
index b178868591..bd4edc7993 100644
--- a/indra/llcommon/lluuid.h
+++ b/indra/llcommon/lluuid.h
@@ -82,8 +82,6 @@ public:
// to integers, among other things. Use isNull() or notNull().
// operator bool() const;
- // JC: These must return real bool's (not BOOLs) or else use of the STL
- // will generate bool-to-int performance warnings.
bool operator==(const LLUUID &rhs) const;
bool operator!=(const LLUUID &rhs) const;
bool operator<(const LLUUID &rhs) const;
diff --git a/indra/llcommon/tests/commonmisc_test.cpp b/indra/llcommon/tests/commonmisc_test.cpp
index 3deb864c0c..0057a1f639 100644
--- a/indra/llcommon/tests/commonmisc_test.cpp
+++ b/indra/llcommon/tests/commonmisc_test.cpp
@@ -67,7 +67,7 @@ namespace tut
std::ostringstream resp;
resp << "{'connect':true, 'position':[r128,r128,r128], 'look_at':[r0,r1,r0], 'agent_access':'M', 'region_x':i8192, 'region_y':i8192}";
std::string str = resp.str();
- LLMemoryStream mstr((U8*)str.c_str(), str.size());
+ LLMemoryStream mstr((U8*)str.c_str(), static_cast<S32>(str.size()));
LLSD response;
S32 count = LLSDSerialize::fromNotation(response, mstr, str.size());
ensure("stream parsed", response.isDefined());
@@ -252,7 +252,7 @@ namespace tut
resp << "{'label':'short binary test', 'singlebinary':b(1)\"A\", 'singlerawstring':s(1)\"A\", 'endoftest':'end' }";
std::string str = resp.str();
LLSD sd;
- LLMemoryStream mstr((U8*)str.c_str(), str.size());
+ LLMemoryStream mstr((U8*)str.c_str(), static_cast<S32>(str.size()));
S32 count = LLSDSerialize::fromNotation(sd, mstr, str.size());
ensure_equals("parse count", count, 5);
ensure("sd created", sd.isDefined());
@@ -456,7 +456,7 @@ namespace tut
void mem_object::test<1>()
{
const char HELLO_WORLD[] = "hello world";
- LLMemoryStream mem((U8*)&HELLO_WORLD[0], strlen(HELLO_WORLD)); /* Flawfinder: ignore */
+ LLMemoryStream mem((U8*)&HELLO_WORLD[0], static_cast<S32>(strlen(HELLO_WORLD))); /* Flawfinder: ignore */
std::string hello;
std::string world;
mem >> hello >> world;
diff --git a/indra/llcommon/tests/lleventdispatcher_test.cpp b/indra/llcommon/tests/lleventdispatcher_test.cpp
index a99acba848..44f772e322 100644
--- a/indra/llcommon/tests/lleventdispatcher_test.cpp
+++ b/indra/llcommon/tests/lleventdispatcher_test.cpp
@@ -491,7 +491,7 @@ namespace tut
// Partial defaults arrays.
for (LLSD::String a: ab)
{
- LLSD::Integer partition(std::min(partial_offset, dft_array_full[a].size()));
+ LLSD::Integer partition(static_cast<LLSD::Integer>(std::min(partial_offset, dft_array_full[a].size())));
dft_array_partial[a] =
llsd_copy_array(dft_array_full[a].beginArray() + partition,
dft_array_full[a].endArray());
@@ -508,7 +508,7 @@ namespace tut
// (params, dft_array_full). Part of the point of using map-style
// defaults is to allow any subset of the target function's
// parameters to be optional, not just the rightmost.
- for (LLSD::Integer ix = 0, ixend = params[a].size(); ix < ixend; ix += 2)
+ for (LLSD::Integer ix = 0, ixend = static_cast<LLSD::Integer>(params[a].size()); ix < ixend; ix += 2)
{
dft_map_partial[a][params[a][ix].asString()] = dft_array_full[a][ix];
}
@@ -696,7 +696,7 @@ namespace tut
LLSD zipmap(const LLSD& keys, const LLSD& values)
{
LLSD map;
- for (LLSD::Integer i = 0, iend = keys.size(); i < iend; ++i)
+ for (LLSD::Integer i = 0, iend = static_cast<LLSD::Integer>(keys.size()); i < iend; ++i)
{
// Have to select asString() since you can index an LLSD
// object with either String or Integer.
@@ -955,7 +955,7 @@ namespace tut
allreq[a] = zipmap(params[a], LLSD::emptyArray());
// Same for leftreq, save that we use the subset of the params not
// supplied by dft_array_partial[a].
- LLSD::Integer partition(params[a].size() - dft_array_partial[a].size());
+ LLSD::Integer partition(static_cast<LLSD::Integer>(params[a].size() - dft_array_partial[a].size()));
leftreq[a] = zipmap(llsd_copy_array(params[a].beginArray(),
params[a].beginArray() + partition),
LLSD::emptyArray());
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp
index 56fdc51e82..fb2af1d2db 100644
--- a/indra/llcommon/tests/llsdserialize_test.cpp
+++ b/indra/llcommon/tests/llsdserialize_test.cpp
@@ -701,7 +701,7 @@ namespace tut
"<key>cam</key><real>1.23</real>"
"</map></llsd>",
v,
- v.size() + 1);
+ static_cast<S32>(v.size()) + 1);
}
template<> template<>
@@ -721,7 +721,7 @@ namespace tut
"<key>cam</key><real>1.23</real>"
"</map></llsd>",
v,
- v.size() + 1);
+ static_cast<S32>(v.size()) + 1);
v.clear();
v["amy"] = 23;
@@ -734,7 +734,7 @@ namespace tut
"<key>cam</key><real>1.23</real>"
"</map></llsd>",
v,
- v.size() + 1);
+ static_cast<S32>(v.size()) + 1);
v.clear();
v["amy"] = 23;
@@ -751,7 +751,7 @@ namespace tut
"<key>cam</key><real>1.23</real>"
"</map></llsd>",
v,
- v.size() + 1);
+ static_cast<S32>(v.size()) + 1);
v.clear();
v[0] = 23;
@@ -766,7 +766,7 @@ namespace tut
"<real>1.23</real>"
"</array></llsd>",
v,
- v.size() + 1);
+ static_cast<S32>(v.size()) + 1);
v.clear();
v[0] = 23;
@@ -782,7 +782,7 @@ namespace tut
"<real>1.23</real>"
"</array></llsd>",
v,
- v.size() + 1);
+ static_cast<S32>(v.size()) + 1);
}
template<> template<>
@@ -1405,13 +1405,13 @@ namespace tut
uint32_t size = htonl(1);
memcpy(&vec[1], &size, sizeof(uint32_t));
vec.push_back('k');
- int key_size_loc = vec.size();
+ auto key_size_loc = vec.size();
size = htonl(1); // 1 too short
vec.resize(vec.size() + 4);
memcpy(&vec[key_size_loc], &size, sizeof(uint32_t));
vec.push_back('a'); vec.push_back('m'); vec.push_back('y');
vec.push_back('i');
- int integer_loc = vec.size();
+ auto integer_loc = vec.size();
vec.resize(vec.size() + 4);
uint32_t val_int = htonl(23);
memcpy(&vec[integer_loc], &val_int, sizeof(uint32_t));
@@ -1473,7 +1473,7 @@ namespace tut
memcpy(&vec[1], &size, sizeof(uint32_t));
vec.push_back('"'); vec.push_back('a'); vec.push_back('m');
vec.push_back('y'); vec.push_back('"'); vec.push_back('i');
- int integer_loc = vec.size();
+ auto integer_loc = vec.size();
vec.resize(vec.size() + 4);
uint32_t val_int = htonl(23);
memcpy(&vec[integer_loc], &val_int, sizeof(uint32_t));
diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp
index dbcfb775da..451e60c083 100644
--- a/indra/llcommon/threadpool.cpp
+++ b/indra/llcommon/threadpool.cpp
@@ -3,7 +3,7 @@
* @author Nat Goodspeed
* @date 2021-10-21
* @brief Implementation for threadpool.
- *
+ *
* $LicenseInfo:firstyear=2021&license=viewerlgpl$
* Copyright (c) 2021, Linden Research, Inc.
* $/LicenseInfo$