diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp index 455df13e48d9d2c002062dd5e3998189380e2257..024b7bd5ab499e2cdaadc9646c3af43795c3ce1e 100644 --- a/indra/llxml/llxmlnode.cpp +++ b/indra/llxml/llxmlnode.cpp @@ -623,7 +623,7 @@ bool LLXMLNode::updateNode( child->getAttributeString("value", nodeName); } - if ((nodeName != "") && (updateName == nodeName)) + if ((!nodeName.empty()) && (updateName == nodeName)) { updateNode(child, updateChild); last_child = child; @@ -829,7 +829,7 @@ bool LLXMLNode::getLayeredXMLNode(LLXMLNodePtr& root, { if (paths.empty()) return false; - std::string filename = paths.front(); + std::string const& filename = paths.front(); if (filename.empty()) { return false; @@ -919,7 +919,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const std::string& i if (use_type_decorations) { // ID - if (mID != "") + if (!mID.empty()) { output_stream << indent << " id=\"" << mID << "\"\n"; } @@ -1024,7 +1024,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const std::string& i // erase last \n before attaching final > or /> output_stream.seekp(-1, std::ios::cur); - if (mChildren.isNull() && mValue == "") + if (mChildren.isNull() && mValue.empty()) { output_stream << " />\n"; return; @@ -1299,7 +1299,7 @@ BOOL LLXMLNode::getAttributeU8(const char* name, U8& value ) BOOL LLXMLNode::getAttributeS8(const char* name, S8& value ) { LLXMLNodePtr node; - S32 val; + S32 val = 0; if (!(getAttribute(name, node) && node->getIntValue(1, &val))) { return false; @@ -1311,7 +1311,7 @@ BOOL LLXMLNode::getAttributeS8(const char* name, S8& value ) BOOL LLXMLNode::getAttributeU16(const char* name, U16& value ) { LLXMLNodePtr node; - U32 val; + U32 val = 0; if (!(getAttribute(name, node) && node->getUnsignedValue(1, &val))) { return false; @@ -1323,7 +1323,7 @@ BOOL LLXMLNode::getAttributeU16(const char* name, U16& value ) BOOL LLXMLNode::getAttributeS16(const char* name, S16& value ) { LLXMLNodePtr node; - S32 val; + S32 val = 0; if (!(getAttribute(name, node) && node->getIntValue(1, &val))) { return false; @@ -1542,35 +1542,35 @@ const char *LLXMLNode::parseFloat(const char *str, F64 *dest, U32 precision, Enc { str = skipWhitespace(str); - if (memcmp(str, "inf", 3) == 0) + if (strncmp(str, "inf", 3) == 0) { *(U64 *)dest = 0x7FF0000000000000ll; return str + 3; } - if (memcmp(str, "-inf", 4) == 0) + if (strncmp(str, "-inf", 4) == 0) { *(U64 *)dest = 0xFFF0000000000000ll; return str + 4; } - if (memcmp(str, "1.#INF", 6) == 0) + if (strncmp(str, "1.#INF", 6) == 0) { *(U64 *)dest = 0x7FF0000000000000ll; return str + 6; } - if (memcmp(str, "-1.#INF", 7) == 0) + if (strncmp(str, "-1.#INF", 7) == 0) { *(U64 *)dest = 0xFFF0000000000000ll; return str + 7; } - F64 negative = 1.0f; + F64 negative = 1.0; if (str[0] == '+') { ++str; } if (str[0] == '-') { - negative = -1.0f; + negative = -1.0; ++str; } @@ -1647,7 +1647,7 @@ const char *LLXMLNode::parseFloat(const char *str, F64 *dest, U32 precision, Enc F64 ret = F64(int_part) + (F64(f_part)/F64(1LL<<61)); - F64 exponent = 1.f; + F64 exponent = 1.0; if (str[0] == 'e') { // Scientific notation! @@ -2330,7 +2330,6 @@ void LLXMLNode::setUnsignedValue(U32 length, const U32* array, Encoding encoding new_value.append(llformat("%08X", array[pos])); } } - mValue = new_value; } // TODO -- Handle Base32 @@ -2560,7 +2559,7 @@ void LLXMLNode::setNodeRefValue(U32 length, const LLXMLNode **array) std::string new_value; for (U32 pos=0; pos<length; ++pos) { - if (array[pos]->mID != "") + if (!array[pos]->mID.empty()) { new_value.append(array[pos]->mID); } @@ -2901,7 +2900,8 @@ void LLXMLNode::createUnitTest(S32 max_num_children) { random_node_array[value] = get_rand_node(root); const char *node_name = random_node_array[value]->mName->mString; - for (U32 pos=0; pos<strlen(node_name); ++pos) /* Flawfinder: ignore */ + U32 node_name_size = strlen(node_name); + for (U32 pos=0; pos<node_name_size; ++pos) /* Flawfinder: ignore */ { U32 hash_contrib = U32(node_name[pos]) << ((pos % 4) * 8); noderef_checksum ^= hash_contrib; @@ -3073,7 +3073,8 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer) for (U32 pos=0; pos<node->mLength; ++pos) { const char *node_name = node_array[pos]->mName->mString; - for (U32 pos2=0; pos2<strlen(node_name); ++pos2) /* Flawfinder: ignore */ + U32 node_name_size = strlen(node_name); + for (U32 pos2=0; pos2<node_name_size; ++pos2) /* Flawfinder: ignore */ { U32 hash_contrib = U32(node_name[pos2]) << ((pos2 % 4) * 8); noderef_checksum ^= hash_contrib;