From 9522a0b7c16414fce2103cf58bfdd63aaf0cb01b Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 3 Nov 2022 14:58:32 -0400 Subject: DRTVWR-575: Fix llcommon assumptions that size_t fits in 4 bytes. It's a little distressing how often we have historically coded S32 or U32 to pass a length or index. There are more such assumptions in other viewer subdirectories, but this is a start. --- indra/llcommon/lltracerecording.h | 100 +++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'indra/llcommon/lltracerecording.h') diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 556b7470cf..8b56721f42 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -334,7 +334,7 @@ namespace LLTrace ~PeriodicRecording(); void nextPeriod(); - S32 getNumRecordedPeriods() + auto getNumRecordedPeriods() { // current period counts if not active return mNumRecordedPeriods + (isStarted() ? 0 : 1); @@ -348,24 +348,24 @@ namespace LLTrace const Recording& getLastRecording() const; Recording& getCurRecording(); const Recording& getCurRecording() const; - Recording& getPrevRecording(S32 offset); - const Recording& getPrevRecording(S32 offset) const; + Recording& getPrevRecording(size_t offset); + const Recording& getPrevRecording(size_t offset) const; Recording snapshotCurRecording() const; template - S32 getSampleCount(const StatType& stat, S32 num_periods = S32_MAX) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; + auto getSampleCount(const StatType& stat, size_t num_periods = S32_MAX) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); - S32 num_samples = 0; - for (S32 i = 1; i <= num_periods; i++) + size_t num_samples = 0; + for (size_t i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); num_samples += recording.getSampleCount(stat); } return num_samples; - } + } // // PERIODIC MIN @@ -373,7 +373,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename T::value_t getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX) + typename T::value_t getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); @@ -396,33 +396,33 @@ namespace LLTrace } template - T getPeriodMin(const CountStatHandle& stat, S32 num_periods = S32_MAX) + T getPeriodMin(const CountStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64 getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX); template - T getPeriodMin(const SampleStatHandle& stat, S32 num_periods = S32_MAX) + T getPeriodMin(const SampleStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64 getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX); template - T getPeriodMin(const EventStatHandle& stat, S32 num_periods = S32_MAX) + T getPeriodMin(const EventStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); - F64Kilobytes getPeriodMin(const MemStatHandle& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMin(const StatType& stat, size_t num_periods = S32_MAX); + F64Kilobytes getPeriodMin(const MemStatHandle& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMinPerSec(const StatType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMinPerSec(const StatType& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); @@ -437,7 +437,7 @@ namespace LLTrace } template - typename RelatedTypes::fractional_t getPeriodMinPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMinPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodMinPerSec(static_cast&>(stat), num_periods)); @@ -449,7 +449,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename T::value_t getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX) + typename T::value_t getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); @@ -472,33 +472,33 @@ namespace LLTrace } template - T getPeriodMax(const CountStatHandle& stat, S32 num_periods = S32_MAX) + T getPeriodMax(const CountStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64 getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX); template - T getPeriodMax(const SampleStatHandle& stat, S32 num_periods = S32_MAX) + T getPeriodMax(const SampleStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64 getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX); template - T getPeriodMax(const EventStatHandle& stat, S32 num_periods = S32_MAX) + T getPeriodMax(const EventStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); - F64Kilobytes getPeriodMax(const MemStatHandle& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMax(const StatType& stat, size_t num_periods = S32_MAX); + F64Kilobytes getPeriodMax(const MemStatHandle& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMaxPerSec(const StatType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMaxPerSec(const StatType& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); @@ -513,7 +513,7 @@ namespace LLTrace } template - typename RelatedTypes::fractional_t getPeriodMaxPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMaxPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodMaxPerSec(static_cast&>(stat), num_periods)); @@ -525,7 +525,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename RelatedTypes::fractional_t getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); @@ -546,32 +546,32 @@ namespace LLTrace } template - typename RelatedTypes::fractional_t getPeriodMean(const CountStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMean(const CountStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64 getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMean(const SampleStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMean(const SampleStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64 getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMean(const EventStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMean(const EventStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); - F64Kilobytes getPeriodMean(const MemStatHandle& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMean(const StatType& stat, size_t num_periods = S32_MAX); + F64Kilobytes getPeriodMean(const MemStatHandle& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMeanPerSec(const StatType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMeanPerSec(const StatType& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); @@ -593,16 +593,16 @@ namespace LLTrace } template - typename RelatedTypes::fractional_t getPeriodMeanPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMeanPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodMeanPerSec(static_cast&>(stat), num_periods)); } - F64 getPeriodMedian( const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMedian( const StatType& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMedianPerSec(const StatType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMedianPerSec(const StatType& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; num_periods = llmin(num_periods, getNumRecordedPeriods()); @@ -622,7 +622,7 @@ namespace LLTrace } template - typename RelatedTypes::fractional_t getPeriodMedianPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMedianPerSec(const CountStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodMedianPerSec(static_cast&>(stat), num_periods)); @@ -632,25 +632,25 @@ namespace LLTrace // PERIODIC STANDARD DEVIATION // - F64 getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodStandardDeviation(const StatType& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodStandardDeviation(const SampleStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodStandardDeviation(const SampleStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); } - F64 getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); + F64 getPeriodStandardDeviation(const StatType& stat, size_t num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodStandardDeviation(const EventStatHandle& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodStandardDeviation(const EventStatHandle& stat, size_t num_periods = S32_MAX) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); - F64Kilobytes getPeriodStandardDeviation(const MemStatHandle& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodStandardDeviation(const StatType& stat, size_t num_periods = S32_MAX); + F64Kilobytes getPeriodStandardDeviation(const MemStatHandle& stat, size_t num_periods = S32_MAX); private: // implementation for LLStopWatchControlsMixin @@ -662,8 +662,8 @@ namespace LLTrace private: std::vector mRecordingPeriods; const bool mAutoResize; - S32 mCurPeriod; - S32 mNumRecordedPeriods; + size_t mCurPeriod; + size_t mNumRecordedPeriods; }; PeriodicRecording& get_frame_recording(); -- cgit v1.2.3