From e22d59af162733c9862107a48b85bbc2fb49e477 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sat, 30 Nov 2019 05:45:38 -0800
Subject: [PATCH] Fix some build warnings and errors on linux

---
 indra/llcommon/is_approx_equal_fraction.h  | 1 +
 indra/llcommon/llcommonprecompiled.h       | 4 +++-
 indra/llcommon/llstring.h                  | 3 +++
 indra/llcommon/llthread.cpp                | 2 +-
 indra/llimage/llimageworker.cpp            | 2 +-
 indra/newview/llagentcamera.cpp            | 7 +++----
 indra/newview/lloutfitgallery.cpp          | 2 ++
 indra/newview/llpanelobject.cpp            | 6 +++++-
 indra/newview/llstatusbar.cpp              | 2 ++
 indra/newview/llviewerprecompiledheaders.h | 2 ++
 10 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/indra/llcommon/is_approx_equal_fraction.h b/indra/llcommon/is_approx_equal_fraction.h
index 7989a32e91..e62715dbee 100644
--- a/indra/llcommon/is_approx_equal_fraction.h
+++ b/indra/llcommon/is_approx_equal_fraction.h
@@ -32,6 +32,7 @@
 #define LL_IS_APPROX_EQUAL_FRACTION_H
 
 #include <cmath>
+#include <cstdint>
 
 /**
  * Originally llmath.h contained two complete implementations of
diff --git a/indra/llcommon/llcommonprecompiled.h b/indra/llcommon/llcommonprecompiled.h
index c29e40c651..974588d98f 100644
--- a/indra/llcommon/llcommonprecompiled.h
+++ b/indra/llcommon/llcommonprecompiled.h
@@ -36,7 +36,9 @@
 #include <algorithm>
 #include <atomic>
 #include <array>
-#include <charconv>
+#ifdef LL_WINDOWS
+#include <charconv> // MSVC is the only impl with complete charconv support currently
+#endif
 #include <condition_variable>
 #include <deque>
 #include <functional>
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 162117a80e..0c698e940e 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -55,7 +55,10 @@
 #endif
 
 #include <cstring>
+
+#if LL_WINDOWS
 #include <charconv>
+#endif
 
 const char LL_UNKNOWN_CHAR = '?';
 class LLSD;
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index 4a2c3e50e9..937b8d0e91 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -146,7 +146,7 @@ void LLThread::threadRun()
 
 LLThread::LLThread(std::string name, apr_pool_t *poolp) :
     mPaused(false), 
-    mNativeHandle(nullptr),
+    mNativeHandle(),
     mName(std::move(name)),
     mRunCondition(std::make_unique<LLCondition>()),
     mDataLock(std::make_unique<LLMutex>()),
diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index 38cf691640..301ea5ea8e 100644
--- a/indra/llimage/llimageworker.cpp
+++ b/indra/llimage/llimageworker.cpp
@@ -134,7 +134,7 @@ bool LLImageDecodeThread::ImageRequest::processRequest()
 			{
 				return true; // done (failed)
 			}
-			if (!(mFormattedImage->getWidth() * mFormattedImage->getHeight() * mFormattedImage->getComponents()))
+			if ((mFormattedImage->getWidth() * mFormattedImage->getHeight() * mFormattedImage->getComponents()) <= 0)
 			{
 				return true; // done (failed)
 			}
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index fde0676351..2756227829 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1960,9 +1960,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 		bool fCamAvDistClamped, fCamAvDistLocked = false; float nCamAvDistLimitMin, nCamAvDistLimitMax;
 		if ((fCamAvDistClamped = RlvActions::getCameraAvatarDistanceLimits(nCamAvDistLimitMin, nCamAvDistLimitMax)))
 			fCamAvDistLocked = nCamAvDistLimitMin == nCamAvDistLimitMax;
-		bool fCamOriginDistClamped, fCamOriginDistLocked = false; float nCamOriginDistLimitMin, nCamOriginDistLimitMax;
-		if ((fCamOriginDistClamped = RlvActions::getCameraOriginDistanceLimits(nCamOriginDistLimitMin, nCamOriginDistLimitMax)))
-			fCamOriginDistLocked = nCamOriginDistLimitMin == nCamOriginDistLimitMax;
+		bool fCamOriginDistClamped = false; float nCamOriginDistLimitMin, nCamOriginDistLimitMax;
+		fCamOriginDistClamped = RlvActions::getCameraOriginDistanceLimits(nCamOriginDistLimitMin, nCamOriginDistLimitMax);
 
 		// Check focus distance limits
 		if ( (fCamOriginDistClamped) && (!fCamAvDistLocked) )
@@ -2038,7 +2037,7 @@ bool LLAgentCamera::clampCameraPosition(LLVector3d& posCamGlobal, const LLVector
 		m_fRlvMinDist = true;
 	}
 
-	if (!isnan(nDistMult))
+	if (!llisnan(nDistMult))
 	{
 		posCamGlobal = posCamRefGlobal + nDistMult * offsetCamera;
 		m_posRlvRefGlobal = posCamRefGlobal;
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp
index af8d978fcc..6d10a40dfe 100644
--- a/indra/newview/lloutfitgallery.cpp
+++ b/indra/newview/lloutfitgallery.cpp
@@ -594,7 +594,9 @@ void LLOutfitGallery::onOutfitRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLU
 void LLOutfitGallery::onChangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id)
 {
     if (mSelectedOutfitUUID == category_id)
+    {
         return;
+    }
 
 	auto outfit_iter = mOutfitMap.find(mSelectedOutfitUUID);
 	if (outfit_iter != mOutfitMap.end())
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 69139aa977..b6bedc3559 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -376,7 +376,11 @@ void LLPanelObject::getState( )
 	if ( (rlv_handler_t::isEnabled()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP))) )
 	{
 		if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == objectp->getRootEdit()) )
-			enable_move = enable_scale = enable_rotate = FALSE;
+		{
+			enable_move = FALSE;
+			enable_scale = FALSE;
+			enable_rotate = FALSE;
+		}
 	}
 // [/RLVa:KB]
 
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 7d7caa4a8a..577568d220 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -126,7 +126,9 @@ LLStatusBar::LLStatusBar(const LLRect& rect)
 LLStatusBar::~LLStatusBar()
 {
     if (mCurrencyChangedSlot.connected())
+	{
         mCurrencyChangedSlot.disconnect();
+	}
 
 	delete mBalanceTimer;
 	mBalanceTimer = nullptr;
diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index 7d3f2f6c35..0151985611 100644
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -39,7 +39,9 @@
 
 #include <algorithm>
 #include <atomic>
+#if LL_WINDOWS
 #include <charconv>
+#endif
 #include <condition_variable>
 #include <deque>
 #include <functional>
-- 
GitLab