From 1c638961543909e897bc343d260f300202687723 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 15 Apr 2010 18:00:00 +0100 Subject: Supporting 'read from the end' doesn't make sense (to me), unlike 'write from the end'. Also, more comments. Also, try to avoid a seek when offset==0 in read. To be reviewed by Bao. (transplanted from 60eb013221a83ff76054ab7dcb1d07c108f51a9d) --- indra/llcommon/llapr.cpp | 11 +++++------ indra/llcommon/llapr.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index ed70b1d9f2..7330b00bcf 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -543,14 +543,13 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb return 0; } - S32 off; - if (offset < 0) - off = LLAPRFile::seek(file_handle, APR_END, 0); - else - off = LLAPRFile::seek(file_handle, APR_SET, offset); + llassert(offset >= 0); + + if (offset > 0) + offset = LLAPRFile::seek(file_handle, APR_SET, offset); apr_size_t bytes_read; - if (off < 0) + if (offset < 0) { bytes_read = 0; } diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index c1ad0bfed1..08cf11e593 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -255,12 +255,12 @@ public: // Returns bytes read/written, 0 if read/write fails: static S32 readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); - static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); + static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); // offset<0 means append //******************************************************************************************************************************* }; /** - * @brief Function which approprately logs error or remains quiet on + * @brief Function which appropriately logs error or remains quiet on * APR_SUCCESS. * @return Returns true if status is an error condition. */ -- cgit v1.2.3 From 59446d550522660c47065622812308da190d6a89 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 15 Apr 2010 19:40:58 +0100 Subject: be gentler on negative-offset reads - just do nothing instead of asserting. from bao's review. (transplanted from 061b8b55838634425455ebc4ac046462dfc0e5f1) --- indra/llcommon/llapr.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 7330b00bcf..f030867ec4 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -535,6 +535,11 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset) //static S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) { + if (offset < 0) + { + return 0; // do nothing, negative offsets don't make sense for reads + } + //***************************************** apr_file_t* file_handle = open(filename, pool, APR_READ|APR_BINARY); //***************************************** @@ -543,10 +548,10 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb return 0; } - llassert(offset >= 0); - if (offset > 0) + { offset = LLAPRFile::seek(file_handle, APR_SET, offset); + } apr_size_t bytes_read; if (offset < 0) -- cgit v1.2.3 From ffa71c3486a28118761e2bb0e7d2a03d54a91436 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Apr 2010 11:58:59 -0700 Subject: fix for build error on Windows --- indra/newview/llviewermessage.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra') diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index f55edd76b0..ab35df1101 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -116,6 +116,11 @@ #include "llnotificationmanager.h" // +#if LL_MSVC +// disable boost::lexical_cast warning +#pragma warning (disable:4702) +#endif + // // Constants // -- cgit v1.2.3 From 5dda65c0303d0e3c38e4ab57c26759937af0eeb2 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 15 Apr 2010 20:15:40 +0100 Subject: EXT-4388 Crash in octree line segment intersection code (getMask) Add yet more paranoia-and-return-or-assert, this time for +-INF in input vector. To be reviewed by Bao. (transplanted from 2012f21d23c66179345fb26148cfbe19835b325e) --- indra/llmath/v2math.h | 9 +++++++++ indra/llrender/llimagegl.cpp | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index 9fef8851cc..65f3714313 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -70,6 +70,8 @@ class LLVector2 void setVec(const LLVector2 &vec); // deprecated void setVec(const F32 *vec); // deprecated + inline bool isFinite() const; // checks to see if all values of LLVector2 are finite + F32 length() const; // Returns magnitude of LLVector2 F32 lengthSquared() const; // Returns magnitude squared of LLVector2 F32 normalize(); // Normalizes and returns the magnitude of LLVector2 @@ -215,6 +217,7 @@ inline void LLVector2::setVec(const F32 *vec) mV[VY] = vec[VY]; } + // LLVector2 Magnitude and Normalization Functions inline F32 LLVector2::length(void) const @@ -247,6 +250,12 @@ inline F32 LLVector2::normalize(void) return (mag); } +// checker +inline bool LLVector2::isFinite() const +{ + return (llfinite(mV[VX]) && llfinite(mV[VY])); +} + // deprecated inline F32 LLVector2::magVec(void) const { diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 8addee606b..ff47c57c70 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1738,8 +1738,18 @@ BOOL LLImageGL::getMask(const LLVector2 &tc) if (mPickMask) { - F32 u = tc.mV[0] - floorf(tc.mV[0]); - F32 v = tc.mV[1] - floorf(tc.mV[1]); + F32 u,v; + if (LL_LIKELY(tc.isFinite())) + { + u = tc.mV[0] - floorf(tc.mV[0]); + v = tc.mV[1] - floorf(tc.mV[1]); + } + else + { + LL_WARNS_ONCE("render") << "Ugh, non-finite u/v in mask pick" << LL_ENDL; + u = v = 0.f; + llassert(false); + } if (LL_UNLIKELY(u < 0.f || u > 1.f || v < 0.f || v > 1.f)) -- cgit v1.2.3 From 799e014f2a16d5031d976e9662d3333d65cfc94c Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 15 Apr 2010 20:31:56 +0100 Subject: Backed out changeset eaac19489aa6 Bao agreed with my initial version after all. --- indra/llcommon/llapr.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index f030867ec4..7330b00bcf 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -535,11 +535,6 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset) //static S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) { - if (offset < 0) - { - return 0; // do nothing, negative offsets don't make sense for reads - } - //***************************************** apr_file_t* file_handle = open(filename, pool, APR_READ|APR_BINARY); //***************************************** @@ -548,10 +543,10 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb return 0; } + llassert(offset >= 0); + if (offset > 0) - { offset = LLAPRFile::seek(file_handle, APR_SET, offset); - } apr_size_t bytes_read; if (offset < 0) -- cgit v1.2.3