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-generic.c b/generator/sections/gen-section-generic.c
index e9a2ea0..061ff10 100644
--- a/generator/sections/gen-section-generic.c
+++ b/generator/sections/gen-section-generic.c
@@ -11,28 +11,29 @@
//Generates a single pseudo-random generic processor section, saving the resulting address to the given
//location. Returns the size of the newly created section.
-size_t generate_section_generic(void** location)
+size_t generate_section_generic(void **location)
{
- //Create random bytes.
- size_t size = generate_random_section(location, 192);
+ //Create random bytes.
+ size_t size = generate_random_section(location, 192);
- //Set reserved locations to zero.
- UINT8* start_byte = (UINT8*)*location;
- *((UINT64*)start_byte) &= 0xFFF;
- *(start_byte + 12) &= 0b111;
- *((UINT16*)(start_byte + 14)) = 0x0;
-
- //Ensure CPU brand string does not terminate early.
- for (int i=0; i<128; i++)
- {
- UINT8* byte = start_byte + 24 + i;
- if (*byte == 0x0)
- *byte = rand() % 127 + 1;
+ //Set reserved locations to zero.
+ UINT8 *start_byte = (UINT8 *)*location;
+ *((UINT64 *)start_byte) &= 0xFFF;
+ *(start_byte + 12) &= 0x7;
+ *((UINT16 *)(start_byte + 14)) = 0x0;
- //Null terminate last byte.
- if (i == 127)
- *byte = 0x0;
- }
+ //Ensure CPU brand string does not terminate early.
+ for (int i = 0; i < 128; i++) {
+ UINT8 *byte = start_byte + 24 + i;
+ if (*byte == 0x0) {
+ *byte = rand() % 127 + 1;
+ }
- return size;
-}
\ No newline at end of file
+ //Null terminate last byte.
+ if (i == 127) {
+ *byte = 0x0;
+ }
+ }
+
+ return size;
+}