From 1e8ad1263dbc2a295ca966ccf62e4f6c2e89db9a Mon Sep 17 00:00:00 2001
From: Cinder <cinder@sdf.org>
Date: Fri, 8 Jan 2016 07:26:45 -0700
Subject: [PATCH] Static initialization of several arrays

---
 indra/llcharacter/llmotioncontroller.cpp |  4 +---
 indra/llcommon/llprocessor.cpp           | 18 ++++++------------
 indra/llcommon/llsd.cpp                  |  6 ++----
 indra/llcommon/llstacktrace.cpp          |  3 +--
 indra/llcommon/llstring.cpp              |  6 ++----
 indra/llrender/llimagegl.cpp             |  3 +--
 indra/newview/llhudeffectbeam.cpp        |  3 +--
 indra/newview/llhudeffectlookat.cpp      |  3 +--
 indra/newview/llhudeffectpointat.cpp     |  3 +--
 indra/newview/llhudeffecttrail.cpp       |  3 +--
 indra/newview/llmeshrepository.cpp       |  3 +--
 indra/newview/llviewerjointmesh.cpp      |  3 +--
 12 files changed, 19 insertions(+), 39 deletions(-)

diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index 4309b17b9a..3bbeba7d84 100755
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -557,9 +557,7 @@ static LLTrace::BlockTimerStatHandle FTM_MOTION_ON_UPDATE("Motion onUpdate");
 void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_type)
 {
 	BOOL update_result = TRUE;
-	U8 last_joint_signature[LL_CHARACTER_MAX_JOINTS];
-
-	memset(&last_joint_signature, 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS);
+	U8 last_joint_signature[LL_CHARACTER_MAX_JOINTS] = {0};
 
 	// iterate through active motions in chronological order
 	for (motion_list_t::iterator iter = mActiveMotions.begin();
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 33c9913a5b..1590989321 100755
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -471,8 +471,7 @@ private:
 		unsigned int ids = (unsigned int)cpu_info[0];
 		setConfig(eMaxID, (S32)ids);
 
-		char cpu_vendor[0x20];
-		memset(cpu_vendor, 0, sizeof(cpu_vendor));
+		char cpu_vendor[0x20] = {0};
 		*((int*)cpu_vendor) = cpu_info[1];
 		*((int*)(cpu_vendor+4)) = cpu_info[3];
 		*((int*)(cpu_vendor+8)) = cpu_info[2];
@@ -538,8 +537,7 @@ private:
 		unsigned int ext_ids = cpu_info[0];
 		setConfig(eMaxExtID, 0);
 
-		char cpu_brand_string[0x40];
-		memset(cpu_brand_string, 0, sizeof(cpu_brand_string));
+		char cpu_brand_string[0x40] = {0};
 
 		// Get the information associated with each extended ID.
 		for(unsigned int i=0x80000000; i<=ext_ids; ++i)
@@ -620,16 +618,14 @@ private:
 	{
 		size_t len = 0;
 
-		char cpu_brand_string[0x40];
+		char cpu_brand_string[0x40] = {0};
 		len = sizeof(cpu_brand_string);
-		memset(cpu_brand_string, 0, len);
 		sysctlbyname("machdep.cpu.brand_string", (void*)cpu_brand_string, &len, NULL, 0);
 		cpu_brand_string[0x3f] = 0;
 		setInfo(eBrandName, cpu_brand_string);
 		
-		char cpu_vendor[0x20];
+		char cpu_vendor[0x20] = {0};
 		len = sizeof(cpu_vendor);
-		memset(cpu_vendor, 0, len);
 		sysctlbyname("machdep.cpu.vendor", (void*)cpu_vendor, &len, NULL, 0);
 		cpu_vendor[0x1f] = 0;
 		setInfo(eVendor, cpu_vendor);
@@ -717,8 +713,7 @@ private:
 		LLFILE* cpuinfo_fp = LLFile::fopen(CPUINFO_FILE, "rb");
 		if(cpuinfo_fp)
 		{
-			char line[MAX_STRING];
-			memset(line, 0, MAX_STRING);
+			char line[MAX_STRING] = {0};
 			while(fgets(line, MAX_STRING, cpuinfo_fp))
 			{
 				// /proc/cpuinfo on Linux looks like:
@@ -816,8 +811,7 @@ private:
 		LLFILE* cpuinfo = LLFile::fopen(CPUINFO_FILE, "rb");
 		if(cpuinfo)
 		{
-			char line[MAX_STRING];
-			memset(line, 0, MAX_STRING);
+			char line[MAX_STRING] = {0};
 			while(fgets(line, MAX_STRING, cpuinfo))
 			{
 				line[strlen(line)-1] = ' ';
diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp
index 57aa7d9c07..a020a2c259 100755
--- a/indra/llcommon/llsd.cpp
+++ b/indra/llcommon/llsd.cpp
@@ -741,11 +741,9 @@ const LLSD& LLSD::Impl::undef()
 
 void LLSD::Impl::dumpStats() const
 {
-	S32 type_counts[LLSD::TypeLLSDNumTypes + 1];
-	memset(&type_counts, 0, sizeof(type_counts));
+	S32 type_counts[LLSD::TypeLLSDNumTypes + 1] = {0};
 
-	S32 share_counts[LLSD::TypeLLSDNumTypes + 1];
-	memset(&share_counts, 0, sizeof(share_counts));
+	S32 share_counts[LLSD::TypeLLSDNumTypes + 1] = {0};
 
 	// Add info from all the values this object has
 	calcStats(type_counts, share_counts);
diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp
index 4874002383..2240c71178 100755
--- a/indra/llcommon/llstacktrace.cpp
+++ b/indra/llcommon/llstacktrace.cpp
@@ -69,8 +69,7 @@ bool ll_get_stack_trace(std::vector<std::string>& lines)
 	if(symbolsLoaded)
 	{
 		// create the frames to hold the addresses
-		void* frames[MAX_STACK_DEPTH];
-		memset(frames, 0, sizeof(void*)*MAX_STACK_DEPTH);
+		void* frames[MAX_STACK_DEPTH] = {0};
 		S32 depth = 0;
 
 		// get the addresses
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 6e1e9c4e76..965d9ba5b6 100755
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -644,8 +644,7 @@ std::string ll_convert_wide_to_string(const wchar_t* in, unsigned int code_page)
 			0);
 		// We will need two more bytes for the double NULL ending
 		// created in WideCharToMultiByte().
-		char* pout = new char [len_out + 2];
-		memset(pout, 0, len_out + 2);
+		char* pout = new char [len_out + 2] = {0};
 		if(pout)
 		{
 			WideCharToMultiByte(
@@ -676,9 +675,8 @@ wchar_t* ll_convert_string_to_wide(const std::string& in, unsigned int code_page
 
 	// reserve place to NULL terminator
 	int output_str_len = in.length();
-	wchar_t* w_out = new wchar_t[output_str_len + 1];
+	wchar_t* w_out = new wchar_t[output_str_len + 1] = {0};
 
-	memset(w_out, 0, output_str_len + 1);
 	int real_output_str_len = MultiByteToWideChar (code_page, 0, in.c_str(), in.length(), w_out, output_str_len);
 
 	//looks like MultiByteToWideChar didn't add null terminator to converted string, see EXT-4858.
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 46ed8975e0..915d652707 100755
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1736,8 +1736,7 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 	U32 length = w * h;
 	U32 alphatotal = 0;
 	
-	U32 sample[16];
-	memset(sample, 0, sizeof(U32)*16);
+	U32 sample[16] = {0};
 
 	// generate histogram of quantized alpha.
 	// also add-in the histogram of a 2x2 box-sampled version.  The idea is
diff --git a/indra/newview/llhudeffectbeam.cpp b/indra/newview/llhudeffectbeam.cpp
index 54e683e048..e76f8436eb 100755
--- a/indra/newview/llhudeffectbeam.cpp
+++ b/indra/newview/llhudeffectbeam.cpp
@@ -86,8 +86,7 @@ void LLHUDEffectBeam::packData(LLMessageSystem *mesgsys)
 
 	// Pack the type-specific data.  Uses a fun packed binary format.  Whee!
 	// 16 + 24 + 1 = 41
-	U8 packed_data[41];
-	memset(packed_data, 0, 41);
+	U8 packed_data[41] = {0};
 	if (mSourceObject)
 	{
 		htonmemcpy(packed_data, mSourceObject->mID.mData, MVT_LLUUID, 16);
diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp
index 0b43a9f2da..03e3f2a70a 100755
--- a/indra/newview/llhudeffectlookat.cpp
+++ b/indra/newview/llhudeffectlookat.cpp
@@ -272,8 +272,7 @@ void LLHUDEffectLookAt::packData(LLMessageSystem *mesgsys)
 	LLHUDEffect::packData(mesgsys);
 
 	// Pack the type-specific data.  Uses a fun packed binary format.  Whee!
-	U8 packed_data[PKT_SIZE];
-	memset(packed_data, 0, PKT_SIZE);
+	U8 packed_data[PKT_SIZE] = {0};
 
 	if (mSourceObject)
 	{
diff --git a/indra/newview/llhudeffectpointat.cpp b/indra/newview/llhudeffectpointat.cpp
index 44c8db19c0..25ef64c190 100755
--- a/indra/newview/llhudeffectpointat.cpp
+++ b/indra/newview/llhudeffectpointat.cpp
@@ -102,8 +102,7 @@ void LLHUDEffectPointAt::packData(LLMessageSystem *mesgsys)
 	LLHUDEffect::packData(mesgsys);
 
 	// Pack the type-specific data.  Uses a fun packed binary format.  Whee!
-	U8 packed_data[PKT_SIZE];
-	memset(packed_data, 0, PKT_SIZE);
+	U8 packed_data[PKT_SIZE] = {0};
 
 	if (mSourceObject)
 	{
diff --git a/indra/newview/llhudeffecttrail.cpp b/indra/newview/llhudeffecttrail.cpp
index 2c50499263..dfad332943 100755
--- a/indra/newview/llhudeffecttrail.cpp
+++ b/indra/newview/llhudeffecttrail.cpp
@@ -82,8 +82,7 @@ void LLHUDEffectSpiral::packData(LLMessageSystem *mesgsys)
 	}
 	LLHUDEffect::packData(mesgsys);
 
-	U8 packed_data[56];
-	memset(packed_data, 0, 56);
+	U8 packed_data[56] = {0};
 
 	if (mSourceObject)
 	{
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 295d1d0762..4c44aa3ca9 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -3052,8 +3052,7 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b
 				file.write(data, data_size);
 			
 				// zero out the rest of the file 
-				U8 block[MESH_HEADER_SIZE];
-				memset(block, 0, sizeof(block));
+				U8 block[MESH_HEADER_SIZE] = {0};
 
 				while (bytes-file.tell() > sizeof(block))
 				{
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 2ede268951..c5746aa98b 100755
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -162,8 +162,7 @@ void LLViewerJointMesh::uploadJointMatrices()
 	// upload matrices
 	if (hardware_skinning)
 	{
-		GLfloat mat[45*4];
-		memset(mat, 0, sizeof(GLfloat)*45*4);
+		GLfloat mat[45*4] = {0};
 
 		for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); joint_num++)
 		{
-- 
GitLab