Formatting .c/.h files and fix memory leakage issues

Signed-off-by: John Chung <john.chung@arm.com>
Change-Id: Id8328f412c2724992d80c0b3f895c8f85bc4ae68
diff --git a/generator/sections/gen-section-dmar.c b/generator/sections/gen-section-dmar.c
index 66cc70a..6e405c8 100644
--- a/generator/sections/gen-section-dmar.c
+++ b/generator/sections/gen-section-dmar.c
@@ -11,68 +11,71 @@
 
 //Generates a single pseudo-random generic DMAr error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_dmar_generic(void** location)
+size_t generate_section_dmar_generic(void **location)
 {
-    //Create random bytes.
-    int size = 32;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* reserved = (UINT64*)(bytes + 16);
-    *reserved = 0;
-    *(reserved + 1) = 0;
+	//Create random bytes.
+	int size = 32;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set expected values.
-    *(bytes + 4) = rand() % 0xC; //Fault reason.
-    *(bytes + 5) = rand() % 2; //Access type.
-    *(bytes + 6) = rand() % 2; //Address type.
-    *(bytes + 7) = rand() % 2 + 1; //Architecture type.
+	//Set reserved areas to zero.
+	UINT64 *reserved = (UINT64 *)(bytes + 16);
+	*reserved = 0;
+	*(reserved + 1) = 0;
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
+	//Set expected values.
+	*(bytes + 4) = rand() % 0xC;   //Fault reason.
+	*(bytes + 5) = rand() % 2;     //Access type.
+	*(bytes + 6) = rand() % 2;     //Address type.
+	*(bytes + 7) = rand() % 2 + 1; //Architecture type.
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
 }
 
 //Generates a single pseudo-random VT-d DMAr error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_dmar_vtd(void** location)
+size_t generate_section_dmar_vtd(void **location)
 {
-    //Create random bytes.
-    int size = 144;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    for (int i=0; i<12; i++)
-        *(bytes + 36 + i) = 0; //Reserved bytes 36-47.
-    UINT8* fault_record = bytes + 48;
-    UINT32* reserved = (UINT32*)(fault_record);
-    *reserved &= ~0xFFF; //First 12 bits of fault record.
-    reserved = (UINT32*)(fault_record + 10);
-    *reserved &= ~0x1FFF; //Bits 80-92 of fault record.
-    *(fault_record + 15) &= 0x7; //Very last bit of fault record.
+	//Create random bytes.
+	int size = 144;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
+	//Set reserved areas to zero.
+	for (int i = 0; i < 12; i++) {
+		*(bytes + 36 + i) = 0; //Reserved bytes 36-47.
+	}
+	UINT8 *fault_record = bytes + 48;
+	UINT32 *reserved = (UINT32 *)(fault_record);
+	*reserved &= ~0xFFF;	     //First 12 bits of fault record.
+	reserved = (UINT32 *)(fault_record + 8);
+	*reserved &= ~0x1FFF0000;    //Bits 80-92 of fault record.
+	*(fault_record + 15) &= 0x7; //Very last bit of fault record.
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
 }
 
 //Generates a single pseudo-random IOMMU DMAr error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_dmar_iommu(void** location)
+size_t generate_section_dmar_iommu(void **location)
 {
-    //Create random bytes.
-    int size = 144;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    for (int i=0; i<7; i++)
-        *(bytes + 1 + i) = 0; //Reserved bytes 1 to 7.
-    UINT64* reserved = (UINT64*)(bytes + 24);
-    *reserved = 0; //Reserved bytes 24-31.
-    for (int i=0; i<16; i++)
-        *(bytes + 48 + i) = 0; //Reserved bytes 48-63.
+	//Create random bytes.
+	int size = 144;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Set reserved areas to zero.
+	for (int i = 0; i < 7; i++) {
+		*(bytes + 1 + i) = 0; //Reserved bytes 1 to 7.
+	}
+	UINT64 *reserved = (UINT64 *)(bytes + 24);
+	*reserved = 0;		       //Reserved bytes 24-31.
+	for (int i = 0; i < 16; i++) {
+		*(bytes + 48 + i) = 0; //Reserved bytes 48-63.
+	}
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}