[coreboot-gerrit] New patch to review for coreboot: src/lib: Fix errors detected by checkpatch

Lee Leahy (leroy.p.leahy@intel.com) gerrit at coreboot.org
Mon Mar 6 01:33:48 CET 2017


Lee Leahy (leroy.p.leahy at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18580

-gerrit

commit 3f305fc2dfaa3ef167fe181d93d90db323e6a45f
Author: Lee Leahy <leroy.p.leahy at intel.com>
Date:   Sun Mar 5 10:41:20 2017 -0800

    src/lib: Fix errors detected by checkpatch
    
    Fix most of the errors detected by checkpatch.  The errors and warnings
    that remain are:
    
    ERROR: need consistent spacing around '*' (ctx:WxV)
    +void __gcov_merge_add(gcov_type *counters  __attribute__ ((unused)),
                                     ^
    
    ERROR: need consistent spacing around '*' (ctx:WxV)
    +void __gcov_merge_single(gcov_type *counters  __attribute__ ((unused)),
                                        ^
    
    ERROR: need consistent spacing around '*' (ctx:WxV)
    +void __gcov_merge_delta(gcov_type *counters  __attribute__ ((unused)),
                                       ^
    
    ERROR: need consistent spacing around '*' (ctx:WxV)
    +void __gcov_merge_add(gcov_type *counters  __attribute__ ((unused)),
                                     ^
    
    ERROR: open brace '{' following struct go on the same line
    +struct gcov_fn_buffer
    +{
    
    ERROR: Macros with multiple statements should be enclosed in a do - while loop
    #85: FILE: src/lib/lzmadecode.c:85:
    +#define IfBit0(p)                                               \
    +	RC_NORMALIZE;                                           \
    +	bound = (Range >> kNumBitModelTotalBits) * *(p);        \
    +	if (Code < bound)
    
    ERROR: Macros with complex values should be enclosed in parentheses
    #103: FILE: src/lib/lzmadecode.c:103:
    +#define RC_GET_BIT2(p, mi, A0, A1)              \
    +	IfBit0(p) {                             \
    +		UpdateBit0(p);                  \
    +		mi <<= 1;                       \
    +		A0;                             \
    +	} else {                                \
    +		UpdateBit1(p);                  \
    +		mi = (mi + mi) + 1;             \
    +		A1;                             \
    +	}
    
    ERROR: need consistent spacing around '*' (ctx:WxV)
    #178: FILE: src/lib/lzmadecode.c:178:
    +int LzmaDecodeProperties(CLzmaProperties *propsRes,
                                              ^
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +	fn_buffer->info.ident = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +	fn_buffer->info.lineno_checksum = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +	fn_buffer->info.cfg_checksum = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +		if (gcov_read_unsigned() != GCOV_TAG_FOR_COUNTER(ix)) {
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +		length = GCOV_TAG_COUNTER_NUM(gcov_read_unsigned());
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +crc32_unsigned(gcov_unsigned_t crc32, gcov_unsigned_t value)
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +		crc32 = crc32_unsigned(crc32, gi_ptr->stamp);
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +		crc32 = crc32_unsigned(crc32, gi_ptr->n_functions);
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			crc32 = crc32_unsigned(crc32, gfi_ptr
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			crc32 = crc32_unsigned(crc32,
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				crc32 = crc32_unsigned(crc32, ci_ptr->num);
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +		tag = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				tag = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				f_ix++, tag = gcov_read_unsigned()) {
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +				length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +					tag = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +					length = gcov_read_unsigned();
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			gcov_write_unsigned(gi_ptr->stamp);
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			gcov_write_unsigned(gfi_ptr->ident);
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			gcov_write_unsigned(gfi_ptr->lineno_checksum);
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +			gcov_write_unsigned(gfi_ptr->cfg_checksum);
    
    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
    +		gcov_write_unsigned(0);
    
    WARNING: Macros with flow control statements should be avoided
    #64: FILE: src/lib/lzmadecode.c:64:
    +#define RC_TEST                                         \
    +	do {                                            \
    +		if (Buffer == BufferLim)                \
    +			return LZMA_RESULT_DATA_ERROR;  \
    +	} while (0)
    +
    
    WARNING: Too many leading tabs - consider code refactoring
    #269: FILE: src/lib/lzmadecode.c:269:
    +						if (bit != 0)
    
    WARNING: Too many leading tabs - consider code refactoring
    #271: FILE: src/lib/lzmadecode.c:271:
    +						if (bit == 0)
    
    WARNING: Too many leading tabs - consider code refactoring
    #308: FILE: src/lib/lzmadecode.c:308:
    +						if (nowPos == 0)
    
    WARNING: line over 80 characters
    #309: FILE: src/lib/lzmadecode.c:309:
    +							return LZMA_RESULT_DATA_ERROR;
    
    WARNING: Too many leading tabs - consider code refactoring
    #334: FILE: src/lib/lzmadecode.c:334:
    +						} else {
    
    WARNING: Too many leading tabs - consider code refactoring
    #398: FILE: src/lib/lzmadecode.c:398:
    +						do {
    
    WARNING: Too many leading tabs - consider code refactoring
    #402: FILE: src/lib/lzmadecode.c:402:
    +							if (Code >= Range) {
    
    WARNING: Too many leading tabs - consider code refactoring
    #406: FILE: src/lib/lzmadecode.c:406:
    +						} while (--numDirectBits != 0);
    
    WARNING: Too many leading tabs - consider code refactoring
    #414: FILE: src/lib/lzmadecode.c:414:
    +						do {
    
    WARNING: Too many leading tabs - consider code refactoring
    #420: FILE: src/lib/lzmadecode.c:420:
    +						} while (--numDirectBits != 0);
    
    WARNING: line over 80 characters
    #37: FILE: src/lib/malloc.c:37:
    +		die("Error! memalign: Out of memory (free_mem_ptr >= free_mem_end_ptr)");
    
    WARNING: Avoid line continuations in quoted strings
    #32: FILE: src/lib/tpm_error_messages.h:32:
    +	 "An operation completed successfully\n\
    
    WARNING: Avoid line continuations in quoted strings
    #35: FILE: src/lib/tpm_error_messages.h:35:
    +	 "The clear disable flag is set and all clear operations now require\n\
    
    WARNING: line over 80 characters
    #68: FILE: src/lib/tpm_error_messages.h:68:
    +	 "The TPM has insufficient internal resources to perform the requested action"},
    
    WARNING: Avoid line continuations in quoted strings
    #80: FILE: src/lib/tpm_error_messages.h:80:
    +	 "The calculation is unable to proceed because the existing SHA-1\n\
    
    WARNING: Avoid line continuations in quoted strings
    #85: FILE: src/lib/tpm_error_messages.h:85:
    +	 "The authorization for the second key in a 2 key function\n\
    
    WARNING: Avoid line continuations in quoted strings
    #104: FILE: src/lib/tpm_error_messages.h:104:
    +	 "The command was received in the wrong sequence relative to TPM_Init\n\
    
    WARNING: Avoid line continuations in quoted strings
    #113: FILE: src/lib/tpm_error_messages.h:113:
    +	 "The signature or encryption scheme for this key is incorrect or not\n\
    
    WARNING: Avoid line continuations in quoted strings
    #116: FILE: src/lib/tpm_error_messages.h:116:
    +	 "The size of the data (or blob) parameter is bad or inconsistent\n\
    
    WARNING: Avoid line continuations in quoted strings
    #119: FILE: src/lib/tpm_error_messages.h:119:
    +	 "A mode parameter is bad, such as capArea or subCapArea for\n\
    
    WARNING: Avoid line continuations in quoted strings
    #123: FILE: src/lib/tpm_error_messages.h:123:
    +	 "Either the physicalPresence or physicalPresenceLock bits\n\
    
    WARNING: Avoid line continuations in quoted strings
    #130: FILE: src/lib/tpm_error_messages.h:130:
    +	 "TPM audit construction failed and the underlying command\n\
    
    WARNING: Avoid line continuations in quoted strings
    #133: FILE: src/lib/tpm_error_messages.h:133:
    +	 "TPM audit construction failed and the underlying command\n\
    
    WARNING: line over 80 characters
    #136: FILE: src/lib/tpm_error_messages.h:136:
    +	 "Attempt to reset a PCR register that does not have the resettable attribute"},
    
    WARNING: Avoid line continuations in quoted strings
    #138: FILE: src/lib/tpm_error_messages.h:138:
    +	 "Attempt to reset a PCR register that requires locality\n\
    
    WARNING: line over 80 characters
    #143: FILE: src/lib/tpm_error_messages.h:143:
    +	 "When saving context identified resource type does not match actual resource"},
    
    WARNING: line over 80 characters
    #145: FILE: src/lib/tpm_error_messages.h:145:
    +	 "The TPM is attempting to execute a command only available when in FIPS mode"},
    
    WARNING: Avoid line continuations in quoted strings
    #173: FILE: src/lib/tpm_error_messages.h:173:
    +	 "The key is under control of the TPM Owner and can only be evicted\n\
    
    WARNING: line over 80 characters
    #194: FILE: src/lib/tpm_error_messages.h:194:
    +	 "There was a command executed outside of an exclusive transport session"},
    
    WARNING: Avoid line continuations in quoted strings
    #208: FILE: src/lib/tpm_error_messages.h:208:
    +	 "The atomic process indicated by the submitted DAA command is not\n\
    
    WARNING: Avoid line continuations in quoted strings
    #237: FILE: src/lib/tpm_error_messages.h:237:
    +	 "The TPM is too busy to respond to the command immediately, but\n\
    
    WARNING: Avoid line continuations in quoted strings
    #243: FILE: src/lib/tpm_error_messages.h:243:
    +	 "The TPM is currently executing the actions of TPM_ContinueSelfTest\n\
    
    WARNING: Avoid line continuations in quoted strings
    #246: FILE: src/lib/tpm_error_messages.h:246:
    +	 "The TPM is defending against dictionary attacks and is in some\n\
    
    TEST=Build and run on Galileo Gen2
    
    Change-Id: Ic1fec68e9d0282e44c6b65e84872b2a0dc439bef
    Signed-off-by: Lee Leahy <leroy.p.leahy at intel.com>
---
 src/lib/libgcov.c           | 1443 +++++++++++++++++++++----------------------
 src/lib/lzma.c              |    5 +-
 src/lib/lzmadecode.c        |  672 ++++++++++----------
 src/lib/lzmadecode.h        |   31 +-
 src/lib/memcmp.c            |    2 +-
 src/lib/memmove.c           |    6 +-
 src/lib/memrange.c          |   62 +-
 src/lib/mocked_tlcl.c       |   41 +-
 src/lib/primitive_memtest.c |    4 +-
 src/lib/prog_loaders.c      |    1 -
 src/lib/ramtest.c           |   19 +-
 src/lib/reg_script.c        |   20 +-
 src/lib/rmodule.c           |    8 +-
 src/lib/selfboot.c          |  121 ++--
 src/lib/spd_bin.c           |   12 +-
 src/lib/stack.c             |    8 +-
 src/lib/thread.c            |   17 +-
 src/lib/timer.c             |    4 +-
 src/lib/timer_queue.c       |    6 +-
 src/lib/timestamp.c         |    2 +-
 src/lib/tlcl.c              |   84 ++-
 src/lib/tlcl_internal.h     |   13 +-
 src/lib/tlcl_structures.h   |  234 ++++---
 src/lib/tpm2_tlcl.c         |    5 +-
 24 files changed, 1468 insertions(+), 1352 deletions(-)

diff --git a/src/lib/libgcov.c b/src/lib/libgcov.c
index 1ad14c9..0ec3645 100644
--- a/src/lib/libgcov.c
+++ b/src/lib/libgcov.c
@@ -30,7 +30,7 @@ permissions described in the GCC Runtime Library Exception, version
 typedef s32 pid_t;
 #define gcc_assert(x) ASSERT(x)
 #define fprintf(file, x...) printk(BIOS_ERR, x)
-#define alloca(size)   __builtin_alloca (size)
+#define alloca(size)   __builtin_alloca(size)
 #include "gcov-glue.c"
 
 /* Define MACROs to be used by coreboot compilation.  */
@@ -73,23 +73,23 @@ typedef s32 pid_t;
 /* If libc and its header files are not available, provide dummy functions.  */
 
 #ifdef L_gcov
-void __gcov_init (struct gcov_info *p __attribute__ ((unused))) {}
-void __gcov_flush (void) {}
+void __gcov_init(struct gcov_info *p __attribute__ ((unused))) {}
+void __gcov_flush(void) {}
 #endif
 
 #ifdef L_gcov_merge_add
-void __gcov_merge_add (gcov_type *counters  __attribute__ ((unused)),
-		       unsigned n_counters __attribute__ ((unused))) {}
+void __gcov_merge_add(gcov_type *counters  __attribute__ ((unused)),
+		       unsigned int n_counters __attribute__ ((unused))) {}
 #endif
 
 #ifdef L_gcov_merge_single
-void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)),
-			  unsigned n_counters __attribute__ ((unused))) {}
+void __gcov_merge_single(gcov_type *counters  __attribute__ ((unused)),
+			  unsigned int n_counters __attribute__ ((unused))) {}
 #endif
 
 #ifdef L_gcov_merge_delta
-void __gcov_merge_delta (gcov_type *counters  __attribute__ ((unused)),
-			 unsigned n_counters __attribute__ ((unused))) {}
+void __gcov_merge_delta(gcov_type *counters  __attribute__ ((unused)),
+			 unsigned int n_counters __attribute__ ((unused))) {}
 #endif
 
 #else
@@ -103,7 +103,7 @@ void __gcov_merge_delta (gcov_type *counters  __attribute__ ((unused)),
 #endif
 #else
 void __gcov_merge_add(gcov_type *counters  __attribute__ ((unused)),
-			unsigned n_counters __attribute__ ((unused))) {}
+			unsigned int n_counters __attribute__ ((unused))) {}
 #endif /* __COREBOOT__ */
 
 #ifdef L_gcov
@@ -111,10 +111,10 @@ void __gcov_merge_add(gcov_type *counters  __attribute__ ((unused)),
 
 struct gcov_fn_buffer
 {
-  struct gcov_fn_buffer *next;
-  unsigned fn_ix;
-  struct gcov_fn_info info;
-  /* note gcov_fn_info ends in a trailing array.  */
+	struct gcov_fn_buffer *next;
+	unsigned int fn_ix;
+	struct gcov_fn_info info;
+	/* note gcov_fn_info ends in a trailing array.  */
 };
 
 /* Chain of per-object gcov structures.  */
@@ -128,150 +128,148 @@ static size_t gcov_max_filename = 0;
    Returns zero on success, or -1 if an error occurred.  */
 
 static int
-create_file_directory (char *filename)
+create_file_directory(char *filename)
 {
 #ifdef __COREBOOT__
-  (void) filename;
-  return 0;
+	(void)filename;
+	return 0;
 #else
 #if !defined(TARGET_POSIX_IO) && !defined(_WIN32)
-  (void) filename;
-  return -1;
+	(void)filename;
+	return -1;
 #else
-  char *s;
-
-  s = filename;
-
-  if (HAS_DRIVE_SPEC(s))
-    s += 2;
-  if (IS_DIR_SEPARATOR(*s))
-    ++s;
-  for (; *s != '\0'; s++)
-    if (IS_DIR_SEPARATOR(*s))
-      {
-        char sep = *s;
-	*s  = '\0';
-
-        /* Try to make directory if it doesn't already exist.  */
-        if (access (filename, F_OK) == -1
+	char *s;
+
+	s = filename;
+
+	if (HAS_DRIVE_SPEC(s))
+		s += 2;
+	if (IS_DIR_SEPARATOR(*s))
+		++s;
+	for (; *s != '\0'; s++)
+		if (IS_DIR_SEPARATOR(*s)) {
+			char sep = *s;
+			*s  = '\0';
+
+			/* Try to make directory if it doesn't already exist. */
+			if ((access(filename, F_OK) == -1)
 #ifdef TARGET_POSIX_IO
-            && mkdir (filename, 0755) == -1
+				&& (mkdir(filename, 0755) == -1)
 #else
-            && mkdir (filename) == -1
+				&& (mkdir(filename) == -1)
 #endif
-            /* The directory might have been made by another process.  */
-	    && errno != EEXIST)
-	  {
-            fprintf (stderr, "profiling:%s:Cannot create directory\n",
-		     filename);
-            *s = sep;
-	    return -1;
-	  };
-
-	*s = sep;
-      };
-  return 0;
+				/* The directory might have been made by another
+				 * process.
+				 */
+				&& (errno != EEXIST)) {
+				fprintf(stderr,
+					"profiling:%s:Cannot create directory\n",
+					filename);
+				*s = sep;
+				return -1;
+			};
+
+			*s = sep;
+		};
+	return 0;
 #endif
 #endif
 }
 
 static struct gcov_fn_buffer *
-free_fn_data (const struct gcov_info *gi_ptr, struct gcov_fn_buffer *buffer,
-	      unsigned limit)
+free_fn_data(const struct gcov_info *gi_ptr, struct gcov_fn_buffer *buffer,
+	unsigned int limit)
 {
-  struct gcov_fn_buffer *next;
-  unsigned ix, n_ctr = 0;
-
-  if (!buffer)
-    return 0;
-  next = buffer->next;
-
-  for (ix = 0; ix != limit; ix++)
-    if (gi_ptr->merge[ix])
-      free (buffer->info.ctrs[n_ctr++].values);
-  free (buffer);
-  return next;
+	struct gcov_fn_buffer *next;
+	unsigned int ix, n_ctr = 0;
+
+	if (!buffer)
+		return 0;
+	next = buffer->next;
+
+	for (ix = 0; ix != limit; ix++)
+		if (gi_ptr->merge[ix])
+			free(buffer->info.ctrs[n_ctr++].values);
+	free(buffer);
+	return next;
 }
 
 static struct gcov_fn_buffer **
-buffer_fn_data (const char *filename, const struct gcov_info *gi_ptr,
-		struct gcov_fn_buffer **end_ptr, unsigned fn_ix)
+buffer_fn_data(const char *filename, const struct gcov_info *gi_ptr,
+		struct gcov_fn_buffer **end_ptr, unsigned int fn_ix)
 {
-  unsigned n_ctrs = 0, ix = 0;
-  struct gcov_fn_buffer *fn_buffer;
-  unsigned len;
+	unsigned int n_ctrs = 0, ix = 0;
+	struct gcov_fn_buffer *fn_buffer;
+	unsigned int len;
 
-  for (ix = GCOV_COUNTERS; ix--;)
-    if (gi_ptr->merge[ix])
-      n_ctrs++;
+	for (ix = GCOV_COUNTERS; ix--;)
+		if (gi_ptr->merge[ix])
+			n_ctrs++;
 
-  len = sizeof (*fn_buffer) + sizeof (fn_buffer->info.ctrs[0]) * n_ctrs;
-  fn_buffer = (struct gcov_fn_buffer *)malloc (len);
+	len = sizeof(*fn_buffer) + sizeof(fn_buffer->info.ctrs[0]) * n_ctrs;
+	fn_buffer = (struct gcov_fn_buffer *)malloc(len);
 
-  if (!fn_buffer)
-    goto fail;
+	if (!fn_buffer)
+		goto fail;
 
-  fn_buffer->next = 0;
-  fn_buffer->fn_ix = fn_ix;
-  fn_buffer->info.ident = gcov_read_unsigned ();
-  fn_buffer->info.lineno_checksum = gcov_read_unsigned ();
-  fn_buffer->info.cfg_checksum = gcov_read_unsigned ();
+	fn_buffer->next = 0;
+	fn_buffer->fn_ix = fn_ix;
+	fn_buffer->info.ident = gcov_read_unsigned();
+	fn_buffer->info.lineno_checksum = gcov_read_unsigned();
+	fn_buffer->info.cfg_checksum = gcov_read_unsigned();
 
-  for (n_ctrs = ix = 0; ix != GCOV_COUNTERS; ix++)
-    {
-      gcov_unsigned_t length;
-      gcov_type *values;
+	for (n_ctrs = ix = 0; ix != GCOV_COUNTERS; ix++) {
+		gcov_unsigned_t length;
+		gcov_type *values;
 
-      if (!gi_ptr->merge[ix])
-	continue;
+		if (!gi_ptr->merge[ix])
+			continue;
 
-      if (gcov_read_unsigned () != GCOV_TAG_FOR_COUNTER (ix))
-	{
-	  len = 0;
-	  goto fail;
-	}
+		if (gcov_read_unsigned() != GCOV_TAG_FOR_COUNTER(ix)) {
+			len = 0;
+			goto fail;
+		}
 
-      length = GCOV_TAG_COUNTER_NUM (gcov_read_unsigned ());
-      len = length * sizeof (gcov_type);
-      values = (gcov_type *)malloc (len);
-      if (!values)
-	goto fail;
+		length = GCOV_TAG_COUNTER_NUM(gcov_read_unsigned());
+		len = length * sizeof(gcov_type);
+		values = (gcov_type *)malloc(len);
+		if (!values)
+			goto fail;
 
-      fn_buffer->info.ctrs[n_ctrs].num = length;
-      fn_buffer->info.ctrs[n_ctrs].values = values;
+		fn_buffer->info.ctrs[n_ctrs].num = length;
+		fn_buffer->info.ctrs[n_ctrs].values = values;
 
-      while (length--)
-	*values++ = gcov_read_counter ();
-      n_ctrs++;
-    }
+		while (length--)
+			*values++ = gcov_read_counter();
+		n_ctrs++;
+	}
 
-  *end_ptr = fn_buffer;
-  return &fn_buffer->next;
+	*end_ptr = fn_buffer;
+	return &fn_buffer->next;
 
 fail:
-  fprintf (stderr, "profiling:%s:Function %u %s %u \n", filename, fn_ix,
-	   len ? "cannot allocate" : "counter mismatch", len ? len : ix);
+	fprintf(stderr, "profiling:%s:Function %u %s %u\n", filename, fn_ix,
+		len ? "cannot allocate" : "counter mismatch", len ? len : ix);
 
-  return (struct gcov_fn_buffer **)free_fn_data (gi_ptr, fn_buffer, ix);
+	return (struct gcov_fn_buffer **)free_fn_data(gi_ptr, fn_buffer, ix);
 }
 
 /* Add an unsigned value to the current crc */
 
 static gcov_unsigned_t
-crc32_unsigned (gcov_unsigned_t crc32, gcov_unsigned_t value)
+crc32_unsigned(gcov_unsigned_t crc32, gcov_unsigned_t value)
 {
-  unsigned ix;
+	unsigned int ix;
 
-  for (ix = 32; ix--; value <<= 1)
-    {
-      unsigned feedback;
+	for (ix = 32; ix--; value <<= 1) {
+		unsigned int feedback;
 
-      feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
-      crc32 <<= 1;
-      crc32 ^= feedback;
-    }
+		feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
+		crc32 <<= 1;
+		crc32 ^= feedback;
+	}
 
-  return crc32;
+	return crc32;
 }
 
 /* Check if VERSION of the info block PTR matches libgcov one.
@@ -280,22 +278,21 @@ crc32_unsigned (gcov_unsigned_t crc32, gcov_unsigned_t value)
    instead of value from the info block.  */
 
 static int
-gcov_version (struct gcov_info *ptr, gcov_unsigned_t version,
-	      const char *filename)
+gcov_version(struct gcov_info *ptr, gcov_unsigned_t version,
+	const char *filename)
 {
-  if (version != GCOV_VERSION)
-    {
-      char v[4], e[4];
-
-      GCOV_UNSIGNED2STRING (v, version);
-      GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
-
-      fprintf (stderr,
-	       "profiling:%s:Version mismatch - expected %.4s got %.4s\n",
-	       filename? filename : ptr->filename, e, v);
-      return 0;
-    }
-  return 1;
+	if (version != GCOV_VERSION) {
+		char v[4], e[4];
+
+		GCOV_UNSIGNED2STRING(v, version);
+		GCOV_UNSIGNED2STRING(e, GCOV_VERSION);
+
+		fprintf(stderr,
+			"profiling:%s:Version mismatch - expected %.4s got %.4s\n",
+			filename ? filename : ptr->filename, e, v);
+		return 0;
+	}
+	return 1;
 }
 
 /* Dump the coverage counts. We merge with existing counts when
@@ -306,443 +303,443 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned_t version,
    summaries separate.  */
 
 static void
-gcov_exit (void)
+gcov_exit(void)
 {
-  struct gcov_info *gi_ptr;
-  const struct gcov_fn_info *gfi_ptr;
-  struct gcov_summary this_prg; /* summary for program.  */
-  struct gcov_summary all_prg;  /* summary for all instances of program.  */
-  struct gcov_ctr_summary *cs_ptr;
-  const struct gcov_ctr_info *ci_ptr;
-  unsigned t_ix;
-  int f_ix = 0;
-  gcov_unsigned_t c_num;
-  const char *gcov_prefix;
-  int gcov_prefix_strip = 0;
-  size_t prefix_length;
-  char *gi_filename, *gi_filename_up;
-  gcov_unsigned_t crc32 = 0;
-
-  memset (&all_prg, 0, sizeof (all_prg));
-  /* Find the totals for this execution.  */
-  memset (&this_prg, 0, sizeof (this_prg));
-  for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
-    {
-      crc32 = crc32_unsigned (crc32, gi_ptr->stamp);
-      crc32 = crc32_unsigned (crc32, gi_ptr->n_functions);
-
-      for (f_ix = 0; (unsigned)f_ix != gi_ptr->n_functions; f_ix++)
-	{
-	  gfi_ptr = gi_ptr->functions[f_ix];
-
-	  if (gfi_ptr && gfi_ptr->key != gi_ptr)
-	    gfi_ptr = 0;
-
-	  crc32 = crc32_unsigned (crc32, gfi_ptr ? gfi_ptr->cfg_checksum : 0);
-	  crc32 = crc32_unsigned (crc32,
+	struct gcov_info *gi_ptr;
+	const struct gcov_fn_info *gfi_ptr;
+	struct gcov_summary this_prg; /* summary for program.  */
+	struct gcov_summary all_prg;  /* summary for all instances of program */
+	struct gcov_ctr_summary *cs_ptr;
+	const struct gcov_ctr_info *ci_ptr;
+	unsigned int t_ix;
+	int f_ix = 0;
+	gcov_unsigned_t c_num;
+	const char *gcov_prefix;
+	int gcov_prefix_strip = 0;
+	size_t prefix_length;
+	char *gi_filename, *gi_filename_up;
+	gcov_unsigned_t crc32 = 0;
+
+	memset(&all_prg, 0, sizeof(all_prg));
+	/* Find the totals for this execution.  */
+	memset(&this_prg, 0, sizeof(this_prg));
+	for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) {
+		crc32 = crc32_unsigned(crc32, gi_ptr->stamp);
+		crc32 = crc32_unsigned(crc32, gi_ptr->n_functions);
+
+		for (f_ix = 0; (unsigned int)f_ix != gi_ptr->n_functions;
+			f_ix++) {
+			gfi_ptr = gi_ptr->functions[f_ix];
+
+			if (gfi_ptr && gfi_ptr->key != gi_ptr)
+			gfi_ptr = 0;
+
+			crc32 = crc32_unsigned(crc32, gfi_ptr
+				? gfi_ptr->cfg_checksum : 0);
+			crc32 = crc32_unsigned(crc32,
 				  gfi_ptr ? gfi_ptr->lineno_checksum : 0);
-	  if (!gfi_ptr)
-	    continue;
-
-	  ci_ptr = gfi_ptr->ctrs;
-	  for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
-	    {
-	      if (!gi_ptr->merge[t_ix])
-		continue;
-
-	      cs_ptr = &this_prg.ctrs[t_ix];
-	      cs_ptr->num += ci_ptr->num;
-	      crc32 = crc32_unsigned (crc32, ci_ptr->num);
-
-	      for (c_num = 0; c_num < ci_ptr->num; c_num++)
-		{
-		  cs_ptr->sum_all += ci_ptr->values[c_num];
-		  if (cs_ptr->run_max < ci_ptr->values[c_num])
-		    cs_ptr->run_max = ci_ptr->values[c_num];
+			if (!gfi_ptr)
+				continue;
+
+			ci_ptr = gfi_ptr->ctrs;
+			for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++) {
+				if (!gi_ptr->merge[t_ix])
+					continue;
+
+				cs_ptr = &this_prg.ctrs[t_ix];
+				cs_ptr->num += ci_ptr->num;
+				crc32 = crc32_unsigned(crc32, ci_ptr->num);
+
+				for (c_num = 0; c_num < ci_ptr->num; c_num++) {
+					cs_ptr->sum_all +=
+						ci_ptr->values[c_num];
+					if (cs_ptr->run_max <
+						ci_ptr->values[c_num])
+						cs_ptr->run_max =
+							ci_ptr->values[c_num];
+				}
+				ci_ptr++;
+			}
 		}
-	      ci_ptr++;
-	    }
 	}
-    }
 
 #ifndef __COREBOOT__
-  {
-    /* Check if the level of dirs to strip off specified. */
-    char *tmp = getenv("GCOV_PREFIX_STRIP");
-    if (tmp)
-      {
-	gcov_prefix_strip = atoi (tmp);
-	/* Do not consider negative values. */
-	if (gcov_prefix_strip < 0)
-	  gcov_prefix_strip = 0;
-      }
-  }
-
-  /* Get file name relocation prefix.  Non-absolute values are ignored. */
-  gcov_prefix = getenv("GCOV_PREFIX");
-  if (gcov_prefix)
-    {
-      prefix_length = strlen(gcov_prefix);
-
-      /* Remove an unnecessary trailing '/' */
-      if (IS_DIR_SEPARATOR (gcov_prefix[prefix_length - 1]))
-	prefix_length--;
-    }
-  else
-#endif
-    prefix_length = 0;
-
-  /* If no prefix was specified and a prefix strip, then we assume
-     relative.  */
-  if (gcov_prefix_strip != 0 && prefix_length == 0)
-    {
-      gcov_prefix = ".";
-      prefix_length = 1;
-    }
-  /* Allocate and initialize the filename scratch space plus one.  */
-  gi_filename = (char *) alloca (prefix_length + gcov_max_filename + 2);
-  if (prefix_length)
-    memcpy (gi_filename, gcov_prefix, prefix_length);
-  gi_filename_up = gi_filename + prefix_length;
-
-  /* Now merge each file.  */
-  for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
-    {
-      unsigned n_counts;
-      struct gcov_summary prg; /* summary for this object over all
-				  program.  */
-      struct gcov_ctr_summary *cs_prg, *cs_tprg, *cs_all;
-      int error = 0;
-      gcov_unsigned_t tag, length;
-      gcov_position_t summary_pos = 0;
-      gcov_position_t eof_pos = 0;
-      const char *fname, *s;
-      struct gcov_fn_buffer *fn_buffer = 0;
-      struct gcov_fn_buffer **fn_tail = &fn_buffer;
-
-      fname = gi_ptr->filename;
-
-      /* Avoid to add multiple drive letters into combined path.  */
-      if (prefix_length != 0 && HAS_DRIVE_SPEC(fname))
-        fname += 2;
-
-      /* Build relocated filename, stripping off leading
-         directories from the initial filename if requested. */
-      if (gcov_prefix_strip > 0)
-        {
-          int level = 0;
-          s = fname;
-          if (IS_DIR_SEPARATOR(*s))
-            ++s;
-
-          /* Skip selected directory levels. */
-	  for (; (*s != '\0') && (level < gcov_prefix_strip); s++)
-	    if (IS_DIR_SEPARATOR(*s))
-	      {
-		fname = s;
-		level++;
-	      }
-        }
-
-      /* Update complete filename with stripped original. */
-      if (prefix_length != 0 && !IS_DIR_SEPARATOR (*fname))
-        {
-          /* If prefix is given, add directory separator.  */
-	  strcpy (gi_filename_up, "/");
-	  strcpy (gi_filename_up + 1, fname);
+	{
+		/* Check if the level of dirs to strip off specified. */
+		char *tmp = getenv("GCOV_PREFIX_STRIP");
+		if (tmp) {
+			gcov_prefix_strip = atoi(tmp);
+			/* Do not consider negative values. */
+			if (gcov_prefix_strip < 0)
+				gcov_prefix_strip = 0;
+		}
 	}
-      else
-        strcpy (gi_filename_up, fname);
 
-      if (!gcov_open (gi_filename))
-	{
-	  /* Open failed likely due to missed directory.
-	     Create directory and retry to open file. */
-          if (create_file_directory (gi_filename))
-	    {
-	      fprintf (stderr, "profiling:%s:Skip\n", gi_filename);
-	      continue;
-	    }
-	  if (!gcov_open (gi_filename))
-	    {
-              fprintf (stderr, "profiling:%s:Cannot open\n", gi_filename);
-	      continue;
-	    }
+	/* Get file name relocation prefix.  Non-absolute values are ignored. */
+	gcov_prefix = getenv("GCOV_PREFIX");
+	if (gcov_prefix) {
+		prefix_length = strlen(gcov_prefix);
+
+		/* Remove an unnecessary trailing '/' */
+		if (IS_DIR_SEPARATOR(gcov_prefix[prefix_length - 1]))
+			prefix_length--;
+	} else
+#endif
+	prefix_length = 0;
+
+	/* If no prefix was specified and a prefix strip, then we assume
+	 * relative.
+	 */
+	if (gcov_prefix_strip != 0 && prefix_length == 0) {
+		gcov_prefix = ".";
+		prefix_length = 1;
 	}
+	/* Allocate and initialize the filename scratch space plus one.  */
+	gi_filename = (char *)alloca(prefix_length + gcov_max_filename + 2);
+	if (prefix_length)
+		memcpy(gi_filename, gcov_prefix, prefix_length);
+	gi_filename_up = gi_filename + prefix_length;
+
+	/* Now merge each file.  */
+	for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) {
+		unsigned int n_counts;
+		/* summary for this object over all program.  */
+		struct gcov_summary prg;
+		struct gcov_ctr_summary *cs_prg, *cs_tprg, *cs_all;
+		int error = 0;
+		gcov_unsigned_t tag, length;
+		gcov_position_t summary_pos = 0;
+		gcov_position_t eof_pos = 0;
+		const char *fname, *s;
+		struct gcov_fn_buffer *fn_buffer = 0;
+		struct gcov_fn_buffer **fn_tail = &fn_buffer;
+
+		fname = gi_ptr->filename;
+
+		/* Avoid to add multiple drive letters into combined path.  */
+		if (prefix_length != 0 && HAS_DRIVE_SPEC(fname))
+			fname += 2;
+
+		/* Build relocated filename, stripping off leading
+		 * directories from the initial filename if requested.
+		 */
+		if (gcov_prefix_strip > 0) {
+			int level = 0;
+			s = fname;
+			if (IS_DIR_SEPARATOR(*s))
+				++s;
+
+			/* Skip selected directory levels. */
+			for (; (*s != '\0') && (level < gcov_prefix_strip); s++)
+				if (IS_DIR_SEPARATOR(*s)) {
+					fname = s;
+					level++;
+				}
+		}
 
-      tag = gcov_read_unsigned ();
-      if (tag)
-	{
-	  /* Merge data from file.  */
-	  if (tag != GCOV_DATA_MAGIC)
-	    {
-	      fprintf (stderr, "profiling:%s:Not a gcov data file\n",
-		       gi_filename);
-	      goto read_fatal;
-	    }
-	  length = gcov_read_unsigned ();
-	  if (!gcov_version (gi_ptr, length, gi_filename))
-	    goto read_fatal;
-
-	  length = gcov_read_unsigned ();
-	  if (length != gi_ptr->stamp)
-	    /* Read from a different compilation. Overwrite the file.  */
-	    goto rewrite;
-
-	  /* Look for program summary.  */
-	  for (f_ix = 0;;)
-	    {
-	      struct gcov_summary tmp;
-
-	      eof_pos = gcov_position ();
-	      tag = gcov_read_unsigned ();
-	      if (tag != GCOV_TAG_PROGRAM_SUMMARY)
-		break;
-
-	      f_ix--;
-	      length = gcov_read_unsigned ();
-	      if (length != GCOV_TAG_SUMMARY_LENGTH)
-		goto read_mismatch;
-	      gcov_read_summary (&tmp);
-	      if ((error = gcov_is_error ()))
-		goto read_error;
-	      if (summary_pos || tmp.checksum != crc32)
-		goto next_summary;
-
-	      for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
-		if (tmp.ctrs[t_ix].num != this_prg.ctrs[t_ix].num)
-		  goto next_summary;
-	      prg = tmp;
-	      summary_pos = eof_pos;
-
-	    next_summary:;
-	    }
-
-	  /* Merge execution counts for each function.  */
-	  for (f_ix = 0; (unsigned)f_ix != gi_ptr->n_functions;
-	       f_ix++, tag = gcov_read_unsigned ())
-	    {
-	      gfi_ptr = gi_ptr->functions[f_ix];
-
-	      if (tag != GCOV_TAG_FUNCTION)
-		goto read_mismatch;
-
-	      length = gcov_read_unsigned ();
-	      if (!length)
-		/* This function did not appear in the other program.
-		   We have nothing to merge.  */
-		continue;
-
-	      if (length != GCOV_TAG_FUNCTION_LENGTH)
-		goto read_mismatch;
-
-	      if (!gfi_ptr || gfi_ptr->key != gi_ptr)
-		{
-		  /* This function appears in the other program.  We
-		     need to buffer the information in order to write
-		     it back out -- we'll be inserting data before
-		     this point, so cannot simply keep the data in the
-		     file.  */
-		  fn_tail = buffer_fn_data (gi_filename,
-					    gi_ptr, fn_tail, f_ix);
-		  if (!fn_tail)
-		    goto read_mismatch;
-		  continue;
+		/* Update complete filename with stripped original. */
+		if (prefix_length != 0 && !IS_DIR_SEPARATOR(*fname)) {
+			/* If prefix is given, add directory separator.  */
+			strcpy(gi_filename_up, "/");
+			strcpy(gi_filename_up + 1, fname);
+		} else
+			strcpy(gi_filename_up, fname);
+
+		if (!gcov_open(gi_filename)) {
+			/* Open failed likely due to missed directory.
+			 * Create directory and retry to open file.
+			 */
+			if (create_file_directory(gi_filename)) {
+				fprintf(stderr, "profiling:%s:Skip\n",
+					gi_filename);
+				continue;
+			}
+			if (!gcov_open(gi_filename)) {
+				fprintf(stderr, "profiling:%s:Cannot open\n",
+					gi_filename);
+				continue;
+			}
 		}
 
-	      length = gcov_read_unsigned ();
-	      if (length != gfi_ptr->ident)
-		goto read_mismatch;
-
-	      length = gcov_read_unsigned ();
-	      if (length != gfi_ptr->lineno_checksum)
-		goto read_mismatch;
-
-	      length = gcov_read_unsigned ();
-	      if (length != gfi_ptr->cfg_checksum)
-		goto read_mismatch;
-
-	      ci_ptr = gfi_ptr->ctrs;
-	      for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
-		{
-		  gcov_merge_fn merge = gi_ptr->merge[t_ix];
-
-		  if (!merge)
-		    continue;
-
-		  tag = gcov_read_unsigned ();
-		  length = gcov_read_unsigned ();
-		  if (tag != GCOV_TAG_FOR_COUNTER (t_ix)
-		      || length != GCOV_TAG_COUNTER_LENGTH (ci_ptr->num))
-		    goto read_mismatch;
-		  (*merge) (ci_ptr->values, ci_ptr->num);
-		  ci_ptr++;
+		tag = gcov_read_unsigned();
+		if (tag) {
+			/* Merge data from file.  */
+			if (tag != GCOV_DATA_MAGIC) {
+				fprintf(stderr,
+					"profiling:%s:Not a gcov data file\n",
+					gi_filename);
+				goto read_fatal;
+			}
+			length = gcov_read_unsigned();
+			if (!gcov_version(gi_ptr, length, gi_filename))
+				goto read_fatal;
+
+			length = gcov_read_unsigned();
+			if (length != gi_ptr->stamp)
+				/* Read from a different compilation. Overwrite
+				 * the file.
+				 */
+				goto rewrite;
+
+			/* Look for program summary.  */
+			for (f_ix = 0;;) {
+				struct gcov_summary tmp;
+
+				eof_pos = gcov_position();
+				tag = gcov_read_unsigned();
+				if (tag != GCOV_TAG_PROGRAM_SUMMARY)
+					break;
+
+				f_ix--;
+				length = gcov_read_unsigned();
+				if (length != GCOV_TAG_SUMMARY_LENGTH)
+					goto read_mismatch;
+				gcov_read_summary(&tmp);
+				error = gcov_is_error();
+				if (error)
+					goto read_error;
+				if (summary_pos || tmp.checksum != crc32)
+					goto next_summary;
+
+				for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE;
+					t_ix++)
+					if (tmp.ctrs[t_ix].num !=
+						this_prg.ctrs[t_ix].num)
+						goto next_summary;
+				prg = tmp;
+				summary_pos = eof_pos;
+
+next_summary:
+			}
+
+			/* Merge execution counts for each function.  */
+			for (f_ix = 0; (unsigned int)f_ix !=
+				gi_ptr->n_functions;
+				f_ix++, tag = gcov_read_unsigned()) {
+				gfi_ptr = gi_ptr->functions[f_ix];
+
+				if (tag != GCOV_TAG_FUNCTION)
+					goto read_mismatch;
+
+				length = gcov_read_unsigned();
+				if (!length)
+					/* This function did not appear in the
+					 * other program. We have nothing to
+					 * merge.
+					 */
+					continue;
+
+				if (length != GCOV_TAG_FUNCTION_LENGTH)
+					goto read_mismatch;
+
+				if (!gfi_ptr || gfi_ptr->key != gi_ptr) {
+					/* This function appears in the other
+					 * program.  We need to buffer the
+					 * information in order to write it back
+					 * out -- we'll be inserting data before
+					 * this point, so cannot simply keep the
+					 * data in the file.
+					 */
+					fn_tail = buffer_fn_data(gi_filename,
+						gi_ptr, fn_tail, f_ix);
+					if (!fn_tail)
+						goto read_mismatch;
+					continue;
+				}
+
+				length = gcov_read_unsigned();
+				if (length != gfi_ptr->ident)
+					goto read_mismatch;
+
+				length = gcov_read_unsigned();
+				if (length != gfi_ptr->lineno_checksum)
+					goto read_mismatch;
+
+				length = gcov_read_unsigned();
+				if (length != gfi_ptr->cfg_checksum)
+					goto read_mismatch;
+
+				ci_ptr = gfi_ptr->ctrs;
+				for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) {
+					gcov_merge_fn merge =
+						gi_ptr->merge[t_ix];
+
+					if (!merge)
+						continue;
+
+					tag = gcov_read_unsigned();
+					length = gcov_read_unsigned();
+					if (tag != GCOV_TAG_FOR_COUNTER(t_ix)
+						|| length !=
+						GCOV_TAG_COUNTER_LENGTH(
+							ci_ptr->num))
+						goto read_mismatch;
+					(*merge)(ci_ptr->values, ci_ptr->num);
+					ci_ptr++;
+				}
+				error = gcov_is_error();
+				if (error)
+					goto read_error;
+			}
+
+			if (tag) {
+read_mismatch:
+				fprintf(stderr,
+					"profiling:%s:Merge mismatch for %s %u\n",
+					gi_filename, f_ix >= 0 ? "function" :
+					"summary", f_ix < 0 ? -1 - f_ix : f_ix);
+				goto read_fatal;
+			}
 		}
-	      if ((error = gcov_is_error ()))
-		goto read_error;
-	    }
-
-	  if (tag)
-	    {
-	    read_mismatch:;
-	      fprintf (stderr, "profiling:%s:Merge mismatch for %s %u\n",
-		       gi_filename, f_ix >= 0 ? "function" : "summary",
-		       f_ix < 0 ? -1 - f_ix : f_ix);
-	      goto read_fatal;
-	    }
-	}
-      goto rewrite;
+		goto rewrite;
 
-    read_error:;
-      fprintf (stderr, "profiling:%s:%s merging\n", gi_filename,
-	       error < 0 ? "Overflow": "Error");
+read_error:
+		fprintf(stderr, "profiling:%s:%s merging\n", gi_filename,
+			error < 0 ? "Overflow" : "Error");
 
-      goto read_fatal;
+		goto read_fatal;
 
-    rewrite:;
-      gcov_rewrite ();
-      if (!summary_pos)
-	{
-	  memset (&prg, 0, sizeof (prg));
-	  summary_pos = eof_pos;
-	}
+rewrite:
+		gcov_rewrite();
+		if (!summary_pos) {
+			memset(&prg, 0, sizeof(prg));
+			summary_pos = eof_pos;
+		}
 
-      /* Merge the summaries.  */
-      for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
-	{
-	  cs_prg = &prg.ctrs[t_ix];
-	  cs_tprg = &this_prg.ctrs[t_ix];
-	  cs_all = &all_prg.ctrs[t_ix];
-
-	  if (gi_ptr->merge[t_ix])
-	    {
-	      if (!cs_prg->runs++)
-		cs_prg->num = cs_tprg->num;
-	      cs_prg->sum_all += cs_tprg->sum_all;
-	      if (cs_prg->run_max < cs_tprg->run_max)
-		cs_prg->run_max = cs_tprg->run_max;
-	      cs_prg->sum_max += cs_tprg->run_max;
-	    }
-	  else if (cs_prg->runs)
-	    goto read_mismatch;
-
-	  if (!cs_all->runs && cs_prg->runs)
-	    memcpy (cs_all, cs_prg, sizeof (*cs_all));
-	  else if (!all_prg.checksum
-		   && (!GCOV_LOCKED || cs_all->runs == cs_prg->runs)
-		   && memcmp (cs_all, cs_prg, sizeof (*cs_all)))
-	    {
-	      fprintf (stderr, "profiling:%s:Invocation mismatch - some data files may have been removed%s\n",
-		       gi_filename, GCOV_LOCKED
-		       ? "" : " or concurrently updated without locking support");
-	      all_prg.checksum = ~0u;
-	    }
-	}
+		/* Merge the summaries.  */
+		for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++) {
+			cs_prg = &prg.ctrs[t_ix];
+			cs_tprg = &this_prg.ctrs[t_ix];
+			cs_all = &all_prg.ctrs[t_ix];
+
+			if (gi_ptr->merge[t_ix]) {
+				if (!cs_prg->runs++)
+				cs_prg->num = cs_tprg->num;
+				cs_prg->sum_all += cs_tprg->sum_all;
+				if (cs_prg->run_max < cs_tprg->run_max)
+					cs_prg->run_max = cs_tprg->run_max;
+				cs_prg->sum_max += cs_tprg->run_max;
+			} else if (cs_prg->runs)
+				goto read_mismatch;
+
+			if (!cs_all->runs && cs_prg->runs)
+				memcpy(cs_all, cs_prg, sizeof(*cs_all));
+			else if (!all_prg.checksum
+				&& (!GCOV_LOCKED || cs_all->runs ==
+					cs_prg->runs)
+				&& memcmp(cs_all, cs_prg, sizeof(*cs_all))) {
+				fprintf(stderr,
+					"profiling:%s:Invocation mismatch - some data files may have been removed%s\n",
+					gi_filename, GCOV_LOCKED
+					? "" :
+					" or concurrently updated without locking support");
+				all_prg.checksum = ~0u;
+			}
+		}
 
-      prg.checksum = crc32;
+		prg.checksum = crc32;
 
-      /* Write out the data.  */
-      if (!eof_pos)
-	{
-	  gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
-	  gcov_write_unsigned (gi_ptr->stamp);
-	}
+		/* Write out the data.  */
+		if (!eof_pos) {
+			gcov_write_tag_length(GCOV_DATA_MAGIC, GCOV_VERSION);
+			gcov_write_unsigned(gi_ptr->stamp);
+		}
 
-      if (summary_pos)
-	gcov_seek (summary_pos);
+		if (summary_pos)
+			gcov_seek(summary_pos);
+
+		/* Generate whole program statistics.  */
+		gcov_write_summary(GCOV_TAG_PROGRAM_SUMMARY, &prg);
+
+		if (summary_pos < eof_pos)
+			gcov_seek(eof_pos);
+
+		/* Write execution counts for each function.  */
+		for (f_ix = 0; (unsigned int)f_ix != gi_ptr->n_functions;
+			f_ix++) {
+			unsigned int buffered = 0;
+
+			if (fn_buffer && fn_buffer->fn_ix ==
+				(unsigned int)f_ix) {
+				/* Buffered data from another program.  */
+				buffered = 1;
+				gfi_ptr = &fn_buffer->info;
+				length = GCOV_TAG_FUNCTION_LENGTH;
+			} else {
+				gfi_ptr = gi_ptr->functions[f_ix];
+				if (gfi_ptr && gfi_ptr->key == gi_ptr)
+					length = GCOV_TAG_FUNCTION_LENGTH;
+				else
+					length = 0;
+			}
+
+			gcov_write_tag_length(GCOV_TAG_FUNCTION, length);
+			if (!length)
+				continue;
+
+			gcov_write_unsigned(gfi_ptr->ident);
+			gcov_write_unsigned(gfi_ptr->lineno_checksum);
+			gcov_write_unsigned(gfi_ptr->cfg_checksum);
+
+			ci_ptr = gfi_ptr->ctrs;
+			for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) {
+				if (!gi_ptr->merge[t_ix])
+					continue;
+
+				n_counts = ci_ptr->num;
+				gcov_write_tag_length(
+					GCOV_TAG_FOR_COUNTER(t_ix),
+					GCOV_TAG_COUNTER_LENGTH(n_counts));
+				gcov_type *c_ptr = ci_ptr->values;
+				while (n_counts--)
+					gcov_write_counter(*c_ptr++);
+				ci_ptr++;
+			}
+			if (buffered)
+				fn_buffer = free_fn_data(gi_ptr, fn_buffer,
+					GCOV_COUNTERS);
+		}
 
-      /* Generate whole program statistics.  */
-      gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &prg);
+		gcov_write_unsigned(0);
 
-      if (summary_pos < eof_pos)
-	gcov_seek (eof_pos);
+read_fatal:
+		while (fn_buffer)
+			fn_buffer = free_fn_data(gi_ptr, fn_buffer,
+				GCOV_COUNTERS);
 
-      /* Write execution counts for each function.  */
-      for (f_ix = 0; (unsigned)f_ix != gi_ptr->n_functions; f_ix++)
-	{
-	  unsigned buffered = 0;
-
-	  if (fn_buffer && fn_buffer->fn_ix == (unsigned)f_ix)
-	    {
-	      /* Buffered data from another program.  */
-	      buffered = 1;
-	      gfi_ptr = &fn_buffer->info;
-	      length = GCOV_TAG_FUNCTION_LENGTH;
-	    }
-	  else
-	    {
-	      gfi_ptr = gi_ptr->functions[f_ix];
-	      if (gfi_ptr && gfi_ptr->key == gi_ptr)
-		length = GCOV_TAG_FUNCTION_LENGTH;
-	      else
-		length = 0;
-	    }
-
-	  gcov_write_tag_length (GCOV_TAG_FUNCTION, length);
-	  if (!length)
-	    continue;
-
-	  gcov_write_unsigned (gfi_ptr->ident);
-	  gcov_write_unsigned (gfi_ptr->lineno_checksum);
-	  gcov_write_unsigned (gfi_ptr->cfg_checksum);
-
-	  ci_ptr = gfi_ptr->ctrs;
-	  for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
-	    {
-	      if (!gi_ptr->merge[t_ix])
-		continue;
-
-	      n_counts = ci_ptr->num;
-	      gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix),
-				     GCOV_TAG_COUNTER_LENGTH (n_counts));
-	      gcov_type *c_ptr = ci_ptr->values;
-	      while (n_counts--)
-		gcov_write_counter (*c_ptr++);
-	      ci_ptr++;
-	    }
-	  if (buffered)
-	    fn_buffer = free_fn_data (gi_ptr, fn_buffer, GCOV_COUNTERS);
+		error = gcov_close();
+		if (error)
+			fprintf(stderr, error  < 0 ?
+				"profiling:%s:Overflow writing\n" :
+				"profiling:%s:Error writing\n",
+				gi_filename);
 	}
-
-      gcov_write_unsigned (0);
-
-    read_fatal:;
-      while (fn_buffer)
-	fn_buffer = free_fn_data (gi_ptr, fn_buffer, GCOV_COUNTERS);
-
-      if ((error = gcov_close ()))
-	  fprintf (stderr, error  < 0 ?
-		   "profiling:%s:Overflow writing\n" :
-		   "profiling:%s:Error writing\n",
-		   gi_filename);
-    }
 }
 
 /* Add a new object file onto the bb chain.  Invoked automatically
    when running an object file's global ctors.  */
 
 void
-__gcov_init (struct gcov_info *info)
+__gcov_init(struct gcov_info *info)
 {
-  if (!info->version || !info->n_functions)
-    return;
-  if (gcov_version (info, info->version, 0))
-    {
-      size_t filename_length = strlen(info->filename);
+	if (!info->version || !info->n_functions)
+		return;
+	if (gcov_version(info, info->version, 0)) {
+		size_t filename_length = strlen(info->filename);
 
-      /* Refresh the longest file name information */
-      if (filename_length > gcov_max_filename)
-        gcov_max_filename = filename_length;
+		/* Refresh the longest file name information */
+		if (filename_length > gcov_max_filename)
+			gcov_max_filename = filename_length;
 
 #ifndef __COREBOOT__
-      if (!gcov_list)
-	atexit (gcov_exit);
+		if (!gcov_list)
+			atexit(gcov_exit);
 #endif
 
-      info->next = gcov_list;
-      gcov_list = info;
-    }
-  info->version = 0;
+		info->next = gcov_list;
+		gcov_list = info;
+	}
+	info->version = 0;
 }
 
 /* Called before fork or exec - write out profile information gathered so
@@ -750,33 +747,32 @@ __gcov_init (struct gcov_info *info)
    profile information gathered so far.  */
 
 void
-__gcov_flush (void)
+__gcov_flush(void)
 {
-  const struct gcov_info *gi_ptr;
-
-  gcov_exit ();
-  for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
-    {
-      unsigned f_ix;
-
-      for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
-	{
-	  unsigned t_ix;
-	  const struct gcov_fn_info *gfi_ptr = gi_ptr->functions[f_ix];
-
-	  if (!gfi_ptr || gfi_ptr->key != gi_ptr)
-	    continue;
-	  const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs;
-	  for (t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++)
-	    {
-	      if (!gi_ptr->merge[t_ix])
-		continue;
-
-	      memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num);
-	      ci_ptr++;
-	    }
+	const struct gcov_info *gi_ptr;
+
+	gcov_exit();
+	for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) {
+		unsigned int f_ix;
+
+		for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++) {
+			unsigned int t_ix;
+			const struct gcov_fn_info *gfi_ptr =
+				gi_ptr->functions[f_ix];
+
+			if (!gfi_ptr || gfi_ptr->key != gi_ptr)
+				continue;
+			const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs;
+			for (t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++) {
+				if (!gi_ptr->merge[t_ix])
+					continue;
+
+				memset(ci_ptr->values, 0, sizeof(gcov_type)
+					* ci_ptr->num);
+				ci_ptr++;
+			}
+		}
 	}
-    }
 }
 
 #endif /* L_gcov */
@@ -786,10 +782,10 @@ __gcov_flush (void)
    an array COUNTERS of N_COUNTERS old counters and it reads the same number
    of counters from the gcov file.  */
 void
-__gcov_merge_add (gcov_type *counters, unsigned n_counters)
+__gcov_merge_add(gcov_type *counters, unsigned int n_counters)
 {
-  for (; n_counters; counters++, n_counters--)
-    *counters += gcov_read_counter ();
+	for (; n_counters; counters++, n_counters--)
+		*counters += gcov_read_counter();
 }
 #endif /* L_gcov_merge_add */
 
@@ -798,10 +794,10 @@ __gcov_merge_add (gcov_type *counters, unsigned n_counters)
    an array COUNTERS of N_COUNTERS old counters and it reads the same number
    of counters from the gcov file.  */
 void
-__gcov_merge_ior (gcov_type *counters, unsigned n_counters)
+__gcov_merge_ior(gcov_type *counters, unsigned int n_counters)
 {
-  for (; n_counters; counters++, n_counters--)
-    *counters |= gcov_read_counter ();
+	for (; n_counters; counters++, n_counters--)
+		*counters |= gcov_read_counter();
 }
 #endif
 
@@ -817,30 +813,27 @@ __gcov_merge_ior (gcov_type *counters, unsigned n_counters)
  * -- total number of evaluations of the value
  */
 void
-__gcov_merge_single (gcov_type *counters, unsigned n_counters)
+__gcov_merge_single(gcov_type *counters, unsigned int n_counters)
 {
-  unsigned i, n_measures;
-  gcov_type value, counter, all;
-
-  gcc_assert (!(n_counters % 3));
-  n_measures = n_counters / 3;
-  for (i = 0; i < n_measures; i++, counters += 3)
-    {
-      value = gcov_read_counter ();
-      counter = gcov_read_counter ();
-      all = gcov_read_counter ();
-
-      if (counters[0] == value)
-	counters[1] += counter;
-      else if (counter > counters[1])
-	{
-	  counters[0] = value;
-	  counters[1] = counter - counters[1];
+	unsigned int i, n_measures;
+	gcov_type value, counter, all;
+
+	gcc_assert(!(n_counters % 3));
+	n_measures = n_counters / 3;
+	for (i = 0; i < n_measures; i++, counters += 3) {
+		value = gcov_read_counter();
+		counter = gcov_read_counter();
+		all = gcov_read_counter();
+
+		if (counters[0] == value)
+			counters[1] += counter;
+		else if (counter > counters[1]) {
+			counters[0] = value;
+			counters[1] = counter - counters[1];
+		} else
+			counters[1] -= counter;
+		counters[2] += all;
 	}
-      else
-	counters[1] -= counter;
-      counters[2] += all;
-    }
 }
 #endif /* L_gcov_merge_single */
 
@@ -857,31 +850,29 @@ __gcov_merge_single (gcov_type *counters, unsigned n_counters)
  * -- total number of evaluations of the value
  */
 void
-__gcov_merge_delta (gcov_type *counters, unsigned n_counters)
+__gcov_merge_delta(gcov_type *counters, unsigned int n_counters)
 {
-  unsigned i, n_measures;
-  gcov_type value, counter, all;
-
-  gcc_assert (!(n_counters % 4));
-  n_measures = n_counters / 4;
-  for (i = 0; i < n_measures; i++, counters += 4)
-    {
-      /* last = */ gcov_read_counter ();
-      value = gcov_read_counter ();
-      counter = gcov_read_counter ();
-      all = gcov_read_counter ();
-
-      if (counters[1] == value)
-	counters[2] += counter;
-      else if (counter > counters[2])
-	{
-	  counters[1] = value;
-	  counters[2] = counter - counters[2];
+	unsigned int i, n_measures;
+	gcov_type value, counter, all;
+
+	gcc_assert(!(n_counters % 4));
+	n_measures = n_counters / 4;
+	for (i = 0; i < n_measures; i++, counters += 4) {
+		/* last = */
+		gcov_read_counter();
+		value = gcov_read_counter();
+		counter = gcov_read_counter();
+		all = gcov_read_counter();
+
+		if (counters[1] == value)
+			counters[2] += counter;
+		else if (counter > counters[2]) {
+			counters[1] = value;
+			counters[2] = counter - counters[2];
+		} else
+			counters[2] -= counter;
+		counters[3] += all;
 	}
-      else
-	counters[2] -= counter;
-      counters[3] += all;
-    }
 }
 #endif /* L_gcov_merge_delta */
 
@@ -892,16 +883,16 @@ __gcov_merge_delta (gcov_type *counters, unsigned n_counters)
    instead.  */
 
 void
-__gcov_interval_profiler (gcov_type *counters, gcov_type value,
-			  int start, unsigned steps)
+__gcov_interval_profiler(gcov_type *counters, gcov_type value,
+			  int start, unsigned int steps)
 {
-  gcov_type delta = value - start;
-  if (delta < 0)
-    counters[steps + 1]++;
-  else if (delta >= steps)
-    counters[steps]++;
-  else
-    counters[delta]++;
+	gcov_type delta = value - start;
+	if (delta < 0)
+		counters[steps + 1]++;
+	else if (delta >= steps)
+		counters[steps]++;
+	else
+		counters[delta]++;
 }
 #endif
 
@@ -910,12 +901,12 @@ __gcov_interval_profiler (gcov_type *counters, gcov_type value,
    COUNTERS[0] is incremented.  */
 
 void
-__gcov_pow2_profiler (gcov_type *counters, gcov_type value)
+__gcov_pow2_profiler(gcov_type *counters, gcov_type value)
 {
-  if (value & (value - 1))
-    counters[0]++;
-  else
-    counters[1]++;
+	if (value & (value - 1))
+		counters[0]++;
+	else
+		counters[1]++;
 }
 #endif
 
@@ -930,25 +921,23 @@ __gcov_pow2_profiler (gcov_type *counters, gcov_type value)
    In any case, COUNTERS[2] is incremented.  */
 
 static inline void
-__gcov_one_value_profiler_body (gcov_type *counters, gcov_type value)
+__gcov_one_value_profiler_body(gcov_type *counters, gcov_type value)
 {
-  if (value == counters[0])
-    counters[1]++;
-  else if (counters[1] == 0)
-    {
-      counters[1] = 1;
-      counters[0] = value;
-    }
-  else
-    counters[1]--;
-  counters[2]++;
+	if (value == counters[0])
+		counters[1]++;
+	else if (counters[1] == 0) {
+		counters[1] = 1;
+		counters[0] = value;
+	} else
+		counters[1]--;
+	counters[2]++;
 }
 
 #ifdef L_gcov_one_value_profiler
 void
-__gcov_one_value_profiler (gcov_type *counters, gcov_type value)
+__gcov_one_value_profiler(gcov_type *counters, gcov_type value)
 {
-  __gcov_one_value_profiler_body (counters, value);
+	__gcov_one_value_profiler_body(counters, value);
 }
 #endif
 
@@ -973,16 +962,16 @@ __gcov_one_value_profiler (gcov_type *counters, gcov_type value)
 
 /* Tries to determine the most common value among its inputs. */
 void
-__gcov_indirect_call_profiler (gcov_type* counter, gcov_type value,
-			       void* cur_func, void* callee_func)
+__gcov_indirect_call_profiler(gcov_type *counter, gcov_type value,
+			       void *cur_func, void *callee_func)
 {
-  /* If the C++ virtual tables contain function descriptors then one
-     function may have multiple descriptors and we need to dereference
-     the descriptors to see if they point to the same function.  */
-  if (cur_func == callee_func
-      || (VTABLE_USES_DESCRIPTORS && callee_func
-	  && *(void **) cur_func == *(void **) callee_func))
-    __gcov_one_value_profiler_body (counter, value);
+	/* If the C++ virtual tables contain function descriptors then one
+	 * function may have multiple descriptors and we need to dereference
+	 * the descriptors to see if they point to the same function.
+	 */
+	if (cur_func == callee_func || (VTABLE_USES_DESCRIPTORS && callee_func
+		&& *(void **)cur_func == *(void **)callee_func))
+		__gcov_one_value_profiler_body(counter, value);
 }
 #endif
 
@@ -992,10 +981,10 @@ __gcov_indirect_call_profiler (gcov_type* counter, gcov_type value,
    to saturate up.  */
 
 void
-__gcov_average_profiler (gcov_type *counters, gcov_type value)
+__gcov_average_profiler(gcov_type *counters, gcov_type value)
 {
-  counters[0] += value;
-  counters[1] ++;
+	counters[0] += value;
+	counters[1]++;
 }
 #endif
 
@@ -1004,9 +993,9 @@ __gcov_average_profiler (gcov_type *counters, gcov_type value)
    to saturate up.  */
 
 void
-__gcov_ior_profiler (gcov_type *counters, gcov_type value)
+__gcov_ior_profiler(gcov_type *counters, gcov_type value)
 {
-  *counters |= value;
+	*counters |= value;
 }
 #endif
 
@@ -1015,10 +1004,10 @@ __gcov_ior_profiler (gcov_type *counters, gcov_type value)
    that they are not counted twice.  */
 
 pid_t
-__gcov_fork (void)
+__gcov_fork(void)
 {
-  __gcov_flush ();
-  return fork ();
+	__gcov_flush();
+	return fork();
 }
 #endif
 
@@ -1027,93 +1016,93 @@ __gcov_fork (void)
    that they are not lost.  */
 
 int
-__gcov_execl (const char *path, char *arg, ...)
+__gcov_execl(const char *path, char *arg, ...)
 {
-  va_list ap, aq;
-  unsigned i, length;
-  char **args;
+	va_list ap, aq;
+	unsigned int i, length;
+	char **args;
 
-  __gcov_flush ();
+	__gcov_flush();
 
-  va_start (ap, arg);
-  va_copy (aq, ap);
+	va_start(ap, arg);
+	va_copy(aq, ap);
 
-  length = 2;
-  while (va_arg (ap, char *))
-    length++;
-  va_end (ap);
+	length = 2;
+	while (va_arg(ap, char *))
+		length++;
+	va_end(ap);
 
-  args = (char **) alloca (length * sizeof (void *));
-  args[0] = arg;
-  for (i = 1; i < length; i++)
-    args[i] = va_arg (aq, char *);
-  va_end (aq);
+	args = (char **)alloca(length * sizeof(void *));
+	args[0] = arg;
+	for (i = 1; i < length; i++)
+		args[i] = va_arg(aq, char *);
+	va_end(aq);
 
-  return execv (path, args);
+	return execv(path, args);
 }
 #endif
 
 #ifdef L_gcov_execlp
-/* A wrapper for the execlp function.  Flushes the accumulated profiling data, so
-   that they are not lost.  */
-
+/* A wrapper for the execlp function.  Flushes the accumulated profiling data,
+ * so that they are not lost.
+ */
 int
-__gcov_execlp (const char *path, char *arg, ...)
+__gcov_execlp(const char *path, char *arg, ...)
 {
-  va_list ap, aq;
-  unsigned i, length;
-  char **args;
+	va_list ap, aq;
+	unsigned int i, length;
+	char **args;
 
-  __gcov_flush ();
+	__gcov_flush();
 
-  va_start (ap, arg);
-  va_copy (aq, ap);
+	va_start(ap, arg);
+	va_copy(aq, ap);
 
-  length = 2;
-  while (va_arg (ap, char *))
-    length++;
-  va_end (ap);
+	length = 2;
+	while (va_arg(ap, char *))
+		length++;
+	va_end(ap);
 
-  args = (char **) alloca (length * sizeof (void *));
-  args[0] = arg;
-  for (i = 1; i < length; i++)
-    args[i] = va_arg (aq, char *);
-  va_end (aq);
+	args = (char **)alloca(length * sizeof(void *));
+	args[0] = arg;
+	for (i = 1; i < length; i++)
+		args[i] = va_arg(aq, char *);
+	va_end(aq);
 
-  return execvp (path, args);
+	return execvp(path, args);
 }
 #endif
 
 #ifdef L_gcov_execle
-/* A wrapper for the execle function.  Flushes the accumulated profiling data, so
-   that they are not lost.  */
-
+/* A wrapper for the execle function.  Flushes the accumulated profiling data,
+ * so that they are not lost.
+ */
 int
-__gcov_execle (const char *path, char *arg, ...)
+__gcov_execle(const char *path, char *arg, ...)
 {
-  va_list ap, aq;
-  unsigned i, length;
-  char **args;
-  char **envp;
+	va_list ap, aq;
+	unsigned int i, length;
+	char **args;
+	char **envp;
 
-  __gcov_flush ();
+	__gcov_flush();
 
-  va_start (ap, arg);
-  va_copy (aq, ap);
+	va_start(ap, arg);
+	va_copy(aq, ap);
 
-  length = 2;
-  while (va_arg (ap, char *))
-    length++;
-  va_end (ap);
+	length = 2;
+	while (va_arg(ap, char *))
+		length++;
+	va_end(ap);
 
-  args = (char **) alloca (length * sizeof (void *));
-  args[0] = arg;
-  for (i = 1; i < length; i++)
-    args[i] = va_arg (aq, char *);
-  envp = va_arg (aq, char **);
-  va_end (aq);
+	args = (char **)alloca(length * sizeof(void *));
+	args[0] = arg;
+	for (i = 1; i < length; i++)
+		args[i] = va_arg(aq, char *);
+	envp = va_arg(aq, char **);
+	va_end(aq);
 
-  return execve (path, args, envp);
+	return execve(path, args, envp);
 }
 #endif
 
@@ -1122,34 +1111,34 @@ __gcov_execle (const char *path, char *arg, ...)
    that they are not lost.  */
 
 int
-__gcov_execv (const char *path, char *const argv[])
+__gcov_execv(const char *path, char *const argv[])
 {
-  __gcov_flush ();
-  return execv (path, argv);
+	__gcov_flush();
+	return execv(path, argv);
 }
 #endif
 
 #ifdef L_gcov_execvp
-/* A wrapper for the execvp function.  Flushes the accumulated profiling data, so
-   that they are not lost.  */
-
+/* A wrapper for the execvp function.  Flushes the accumulated profiling data,
+ * so that they are not lost.
+ */
 int
-__gcov_execvp (const char *path, char *const argv[])
+__gcov_execvp(const char *path, char *const argv[])
 {
-  __gcov_flush ();
-  return execvp (path, argv);
+	__gcov_flush();
+	return execvp(path, argv);
 }
 #endif
 
 #ifdef L_gcov_execve
-/* A wrapper for the execve function.  Flushes the accumulated profiling data, so
-   that they are not lost.  */
-
+/* A wrapper for the execve function.  Flushes the accumulated profiling data,
+ * so that they are not lost.
+ */
 int
-__gcov_execve (const char *path, char *const argv[], char *const envp[])
+__gcov_execve(const char *path, char *const argv[], char *const envp[])
 {
-  __gcov_flush ();
-  return execve (path, argv, envp);
+	__gcov_flush();
+	return execve(path, argv, envp);
 }
 #endif
 #endif /* inhibit_libc */
diff --git a/src/lib/lzma.c b/src/lib/lzma.c
index 3efcbc0..f727553 100644
--- a/src/lib/lzma.c
+++ b/src/lib/lzma.c
@@ -4,8 +4,9 @@
  * Copyright (C) 2006 Carl-Daniel Hailfinger
  * Released under the GNU GPL v2 or later
  *
- * Parts of this file are based on C/7zip/Compress/LZMA_C/LzmaTest.c from the LZMA
- * SDK 4.42, which is written and distributed to public domain by Igor Pavlov.
+ * Parts of this file are based on C/7zip/Compress/LZMA_C/LzmaTest.c from the
+ * LZMA SDK 4.42, which is written and distributed to public domain by Igor
+ * Pavlov.
  *
  */
 
diff --git a/src/lib/lzmadecode.c b/src/lib/lzmadecode.c
index fbf1596..1c2f71b 100644
--- a/src/lib/lzmadecode.c
+++ b/src/lib/lzmadecode.c
@@ -33,36 +33,97 @@
  * to byte reads for last 4 bytes since RC_TEST returns an error when BufferLim
  * is *reached* (not surpassed!), meaning we can't allow that to happen while
  * there are still bytes to decode from the algorithm's point of view. */
-#define RC_READ_BYTE (look_ahead_ptr < 4 ? look_ahead.raw[look_ahead_ptr++] \
-		      : ((((uintptr_t) Buffer & 3) || ((SizeT) (BufferLim - Buffer) <= 4)) ? (*Buffer++) \
-	   : ((look_ahead.dw = *(UInt32 *)Buffer), (Buffer += 4), (look_ahead_ptr = 1), look_ahead.raw[0])))
-
-#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
-  { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
-
-
-#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
-
-#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
-
-
-#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
-
-#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
-#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
-#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
-
-#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
-  { UpdateBit0(p); mi <<= 1; A0; } else \
-  { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
-
-#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
-
-#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
-  { int i = numLevels; res = 1; \
-  do { CProb *cp = probs + res; RC_GET_BIT(cp, res) } while(--i != 0); \
-  res -= (1 << numLevels); }
-
+#define RC_READ_BYTE                                                    \
+	(look_ahead_ptr < 4                                             \
+		? look_ahead.raw[look_ahead_ptr++]                      \
+		: ((((uintptr_t) Buffer & 3)                            \
+			|| ((SizeT)(BufferLim - Buffer) <= 4))          \
+			? (*Buffer++)                                   \
+			: ((                                            \
+				look_ahead.dw = *(UInt32 *)Buffer),     \
+				(Buffer += 4),                          \
+				(look_ahead_ptr = 1),                   \
+				look_ahead.raw[0]                       \
+			  )                                             \
+		  )                                                     \
+	)
+
+#define RC_INIT2                                                            \
+	do {                                                                \
+		Code = 0;                                                   \
+		Range = 0xFFFFFFFF;                                         \
+		{                                                           \
+			int i;                                              \
+									    \
+			for (i = 0; i < 5; i++) {                           \
+				RC_TEST; Code = (Code << 8) | RC_READ_BYTE; \
+			}                                                   \
+		}                                                           \
+	} while (0)
+
+#define RC_TEST                                         \
+	do {                                            \
+		if (Buffer == BufferLim)                \
+			return LZMA_RESULT_DATA_ERROR;  \
+	} while (0)
+
+#define RC_INIT(buffer, bufferSize)                     \
+	do {                                            \
+		Buffer = buffer;                        \
+		BufferLim = buffer + bufferSize;        \
+		RC_INIT2;                                \
+	} while (0)
+
+#define RC_NORMALIZE                                            \
+	do {                                                    \
+		if (Range < kTopValue) {                        \
+			RC_TEST; Range <<= 8;                   \
+			Code = (Code << 8) | RC_READ_BYTE;      \
+		}                                               \
+	} while (0)
+
+#define IfBit0(p)                                               \
+	RC_NORMALIZE;                                           \
+	bound = (Range >> kNumBitModelTotalBits) * *(p);        \
+	if (Code < bound)
+
+#define UpdateBit0(p)                                                   \
+	do {                                                            \
+		Range = bound;                                          \
+		*(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;        \
+	} while (0)
+
+#define UpdateBit1(p)                           \
+	do {                                    \
+		Range -= bound;                 \
+		Code -= bound;                  \
+		*(p) -= (*(p)) >> kNumMoveBits; \
+	} while (0)
+
+#define RC_GET_BIT2(p, mi, A0, A1)              \
+	IfBit0(p) {                             \
+		UpdateBit0(p);                  \
+		mi <<= 1;                       \
+		A0;                             \
+	} else {                                \
+		UpdateBit1(p);                  \
+		mi = (mi + mi) + 1;             \
+		A1;                             \
+	}
+
+#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ;, ;)
+
+#define RangeDecoderBitTreeDecode(probs, numLevels, res)        \
+	do {                                                    \
+		int i = numLevels;                              \
+								\
+		res = 1;                                        \
+		do {                                            \
+			CProb *cp = probs + res;                \
+			RC_GET_BIT(cp, res)                     \
+		} while (--i != 0);                             \
+		res -= (1 << numLevels);                        \
+	} while (0)
 
 #define kNumPosBitsMax 4
 #define kNumPosStatesMax (1 << kNumPosBitsMax)
@@ -114,298 +175,275 @@
 StopCompilingDueBUG
 #endif
 
-int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
+int LzmaDecodeProperties(CLzmaProperties *propsRes,
+	const unsigned char *propsData, int size)
 {
-  unsigned char prop0;
-  if (size < LZMA_PROPERTIES_SIZE)
-    return LZMA_RESULT_DATA_ERROR;
-  prop0 = propsData[0];
-  if (prop0 >= (9 * 5 * 5))
-    return LZMA_RESULT_DATA_ERROR;
-  {
-    for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
-    for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
-    propsRes->lc = prop0;
-    /*
-    unsigned char remainder = (unsigned char)(prop0 / 9);
-    propsRes->lc = prop0 % 9;
-    propsRes->pb = remainder / 5;
-    propsRes->lp = remainder % 5;
-    */
-  }
-
-  return LZMA_RESULT_OK;
+	unsigned char prop0;
+	if (size < LZMA_PROPERTIES_SIZE)
+		return LZMA_RESULT_DATA_ERROR;
+	prop0 = propsData[0];
+	if (prop0 >= (9 * 5 * 5))
+		return LZMA_RESULT_DATA_ERROR;
+	for (propsRes->pb = 0; prop0 >= (9 * 5);
+		propsRes->pb++, prop0 -= (9 * 5))
+		;
+	for (propsRes->lp = 0; prop0 >= 9;
+		propsRes->lp++, prop0 -= 9)
+		;
+	propsRes->lc = prop0;
+	/*
+	unsigned char remainder = (unsigned char)(prop0
+		 / 9);
+	propsRes->lc = prop0 % 9;
+	propsRes->pb = remainder / 5;
+	propsRes->lp = remainder % 5;
+	*/
+
+	return LZMA_RESULT_OK;
 }
 
 #define kLzmaStreamWasFinishedId (-1)
 
 int LzmaDecode(CLzmaDecoderState *vs,
-    const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
-    unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
+	const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+	unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
 {
-  CProb *p = vs->Probs;
-  SizeT nowPos = 0;
-  Byte previousByte = 0;
-  UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
-  UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
-  int lc = vs->Properties.lc;
-
-
-  int state = 0;
-  UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
-  int len = 0;
-  const Byte *Buffer;
-  const Byte *BufferLim;
-  int look_ahead_ptr = 4;
-  union
-  {
-	  Byte raw[4];
-	  UInt32 dw;
-  } look_ahead;
-  UInt32 Range;
-  UInt32 Code;
-
-  *inSizeProcessed = 0;
-  *outSizeProcessed = 0;
-
-  {
-    UInt32 i;
-    UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
-    for (i = 0; i < numProbs; i++)
-      p[i] = kBitModelTotal >> 1;
-  }
-
-  RC_INIT(inStream, inSize);
-
-
-  while(nowPos < outSize)
-  {
-    CProb *prob;
-    UInt32 bound;
-    int posState = (int)(
-        (nowPos
-        )
-        & posStateMask);
-
-    prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
-    IfBit0(prob)
-    {
-      int symbol = 1;
-      UpdateBit0(prob)
-      prob = p + Literal + (LZMA_LIT_SIZE *
-        (((
-        (nowPos
-        )
-        & literalPosMask) << lc) + (previousByte >> (8 - lc))));
-
-      if (state >= kNumLitStates)
-      {
-        int matchByte;
-        matchByte = outStream[nowPos - rep0];
-        do
-        {
-          int bit;
-          CProb *probLit;
-          matchByte <<= 1;
-          bit = (matchByte & 0x100);
-          probLit = prob + 0x100 + bit + symbol;
-          RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
-        }
-        while (symbol < 0x100);
-      }
-      while (symbol < 0x100)
-      {
-        CProb *probLit = prob + symbol;
-        RC_GET_BIT(probLit, symbol)
-      }
-      previousByte = (Byte)symbol;
-
-      outStream[nowPos++] = previousByte;
-      if (state < 4) state = 0;
-      else if (state < 10) state -= 3;
-      else state -= 6;
-    }
-    else
-    {
-      UpdateBit1(prob);
-      prob = p + IsRep + state;
-      IfBit0(prob)
-      {
-        UpdateBit0(prob);
-        rep3 = rep2;
-        rep2 = rep1;
-        rep1 = rep0;
-        state = state < kNumLitStates ? 0 : 3;
-        prob = p + LenCoder;
-      }
-      else
-      {
-        UpdateBit1(prob);
-        prob = p + IsRepG0 + state;
-        IfBit0(prob)
-        {
-          UpdateBit0(prob);
-          prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
-          IfBit0(prob)
-          {
-            UpdateBit0(prob);
-
-            if (nowPos == 0)
-              return LZMA_RESULT_DATA_ERROR;
-
-            state = state < kNumLitStates ? 9 : 11;
-            previousByte = outStream[nowPos - rep0];
-            outStream[nowPos++] = previousByte;
-
-            continue;
-          }
-          else
-          {
-            UpdateBit1(prob);
-          }
-        }
-        else
-        {
-          UInt32 distance;
-          UpdateBit1(prob);
-          prob = p + IsRepG1 + state;
-          IfBit0(prob)
-          {
-            UpdateBit0(prob);
-            distance = rep1;
-          }
-          else
-          {
-            UpdateBit1(prob);
-            prob = p + IsRepG2 + state;
-            IfBit0(prob)
-            {
-              UpdateBit0(prob);
-              distance = rep2;
-            }
-            else
-            {
-              UpdateBit1(prob);
-              distance = rep3;
-              rep3 = rep2;
-            }
-            rep2 = rep1;
-          }
-          rep1 = rep0;
-          rep0 = distance;
-        }
-        state = state < kNumLitStates ? 8 : 11;
-        prob = p + RepLenCoder;
-      }
-      {
-        int numBits, offset;
-        CProb *probLen = prob + LenChoice;
-        IfBit0(probLen)
-        {
-          UpdateBit0(probLen);
-          probLen = prob + LenLow + (posState << kLenNumLowBits);
-          offset = 0;
-          numBits = kLenNumLowBits;
-        }
-        else
-        {
-          UpdateBit1(probLen);
-          probLen = prob + LenChoice2;
-          IfBit0(probLen)
-          {
-            UpdateBit0(probLen);
-            probLen = prob + LenMid + (posState << kLenNumMidBits);
-            offset = kLenNumLowSymbols;
-            numBits = kLenNumMidBits;
-          }
-          else
-          {
-            UpdateBit1(probLen);
-            probLen = prob + LenHigh;
-            offset = kLenNumLowSymbols + kLenNumMidSymbols;
-            numBits = kLenNumHighBits;
-          }
-        }
-        RangeDecoderBitTreeDecode(probLen, numBits, len);
-        len += offset;
-      }
-
-      if (state < 4)
-      {
-        int posSlot;
-        state += kNumLitStates;
-        prob = p + PosSlot +
-            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
-            kNumPosSlotBits);
-        RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
-        if (posSlot >= kStartPosModelIndex)
-        {
-          int numDirectBits = ((posSlot >> 1) - 1);
-          rep0 = (2 | ((UInt32)posSlot & 1));
-          if (posSlot < kEndPosModelIndex)
-          {
-            rep0 <<= numDirectBits;
-            prob = p + SpecPos + rep0 - posSlot - 1;
-          }
-          else
-          {
-            numDirectBits -= kNumAlignBits;
-            do
-            {
-              RC_NORMALIZE
-              Range >>= 1;
-              rep0 <<= 1;
-              if (Code >= Range)
-              {
-                Code -= Range;
-                rep0 |= 1;
-              }
-            }
-            while (--numDirectBits != 0);
-            prob = p + Align;
-            rep0 <<= kNumAlignBits;
-            numDirectBits = kNumAlignBits;
-          }
-          {
-            int i = 1;
-            int mi = 1;
-            do
-            {
-              CProb *prob3 = prob + mi;
-              RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
-              i <<= 1;
-            }
-            while(--numDirectBits != 0);
-          }
-        }
-        else
-          rep0 = posSlot;
-        if (++rep0 == (UInt32)(0))
-        {
-          /* it's for stream version */
-          len = kLzmaStreamWasFinishedId;
-          break;
-        }
-      }
-
-      len += kMatchMinLen;
-      if (rep0 > nowPos)
-        return LZMA_RESULT_DATA_ERROR;
-
-
-      do
-      {
-        previousByte = outStream[nowPos - rep0];
-        len--;
-        outStream[nowPos++] = previousByte;
-      }
-      while(len != 0 && nowPos < outSize);
-    }
-  }
-  RC_NORMALIZE;
-
-
-  *inSizeProcessed = (SizeT)(Buffer - inStream);
-  *outSizeProcessed = nowPos;
-  return LZMA_RESULT_OK;
+	CProb *p = vs->Probs;
+	SizeT nowPos = 0;
+	Byte previousByte = 0;
+	UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
+	UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
+	int lc = vs->Properties.lc;
+
+
+	int state = 0;
+	UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
+	int len = 0;
+	const Byte *Buffer;
+	const Byte *BufferLim;
+	int look_ahead_ptr = 4;
+	union {
+		Byte raw[4];
+		UInt32 dw;
+	} look_ahead;
+	UInt32 Range;
+	UInt32 Code;
+
+	*inSizeProcessed = 0;
+	*outSizeProcessed = 0;
+
+	{
+		UInt32 i;
+		UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc +
+			vs->Properties.lp));
+		for (i = 0; i < numProbs; i++)
+			p[i] = kBitModelTotal >> 1;
+	}
+
+	RC_INIT(inStream, inSize);
+
+
+	while (nowPos < outSize) {
+		CProb *prob;
+		UInt32 bound;
+		int posState = (int)((nowPos) & posStateMask);
+
+		prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
+		IfBit0(prob) {
+			int symbol = 1;
+			UpdateBit0(prob);
+			prob = p + Literal + (LZMA_LIT_SIZE * ((((nowPos)
+				& literalPosMask) << lc)
+				+ (previousByte >> (8 - lc))));
+
+			if (state >= kNumLitStates) {
+				int matchByte;
+				matchByte = outStream[nowPos - rep0];
+				do {
+					int bit;
+					CProb *probLit;
+					matchByte <<= 1;
+					bit = (matchByte & 0x100);
+					probLit = prob + 0x100 + bit + symbol;
+					RC_GET_BIT2(probLit, symbol,
+						if (bit != 0)
+							break,
+						if (bit == 0)
+							break)
+				} while (symbol < 0x100);
+			}
+			while (symbol < 0x100) {
+				CProb *probLit = prob + symbol;
+				RC_GET_BIT(probLit, symbol)
+			}
+			previousByte = (Byte)symbol;
+
+			outStream[nowPos++] = previousByte;
+			if (state < 4)
+				state = 0;
+			else if (state < 10)
+				state -= 3;
+			else
+				state -= 6;
+		} else {
+			UpdateBit1(prob);
+			prob = p + IsRep + state;
+			IfBit0(prob) {
+				UpdateBit0(prob);
+				rep3 = rep2;
+				rep2 = rep1;
+				rep1 = rep0;
+				state = state < kNumLitStates ? 0 : 3;
+				prob = p + LenCoder;
+			} else {
+				UpdateBit1(prob);
+				prob = p + IsRepG0 + state;
+				IfBit0(prob) {
+					UpdateBit0(prob);
+					prob = p + IsRep0Long + (state <<
+						kNumPosBitsMax) + posState;
+					IfBit0(prob) {
+						UpdateBit0(prob);
+
+						if (nowPos == 0)
+							return LZMA_RESULT_DATA_ERROR;
+
+						state = state < kNumLitStates
+							? 9 : 11;
+						previousByte = outStream[nowPos
+							- rep0];
+						outStream[nowPos++] =
+							previousByte;
+
+						continue;
+					} else
+						UpdateBit1(prob);
+				} else {
+					UInt32 distance;
+					UpdateBit1(prob);
+					prob = p + IsRepG1 + state;
+					IfBit0(prob) {
+						UpdateBit0(prob);
+						distance = rep1;
+					} else {
+						UpdateBit1(prob);
+						prob = p + IsRepG2 + state;
+						IfBit0(prob) {
+							UpdateBit0(prob);
+							distance = rep2;
+						} else {
+							UpdateBit1(prob);
+							distance = rep3;
+							rep3 = rep2;
+						}
+						rep2 = rep1;
+					}
+					rep1 = rep0;
+					rep0 = distance;
+				}
+				state = state < kNumLitStates ? 8 : 11;
+				prob = p + RepLenCoder;
+			}
+			{
+				int numBits, offset;
+				CProb *probLen = prob + LenChoice;
+				IfBit0(probLen) {
+					UpdateBit0(probLen);
+					probLen = prob + LenLow + (posState
+						<< kLenNumLowBits);
+					offset = 0;
+					numBits = kLenNumLowBits;
+				} else {
+					UpdateBit1(probLen);
+					probLen = prob + LenChoice2;
+					IfBit0(probLen) {
+						UpdateBit0(probLen);
+						probLen = prob + LenMid +
+							(posState <<
+							kLenNumMidBits);
+						offset = kLenNumLowSymbols;
+						numBits = kLenNumMidBits;
+					} else {
+						UpdateBit1(probLen);
+						probLen = prob + LenHigh;
+						offset = kLenNumLowSymbols
+							+ kLenNumMidSymbols;
+						numBits = kLenNumHighBits;
+					}
+				}
+				RangeDecoderBitTreeDecode(probLen, numBits,
+					len);
+				len += offset;
+			}
+
+			if (state < 4) {
+				int posSlot;
+				state += kNumLitStates;
+				prob = p + PosSlot +
+					((len < kNumLenToPosStates ?
+					len : kNumLenToPosStates - 1) <<
+					kNumPosSlotBits);
+				RangeDecoderBitTreeDecode(prob, kNumPosSlotBits,
+					posSlot);
+				if (posSlot >= kStartPosModelIndex) {
+					int numDirectBits = ((posSlot >> 1)
+						- 1);
+					rep0 = (2 | ((UInt32)posSlot & 1));
+					if (posSlot < kEndPosModelIndex) {
+						rep0 <<= numDirectBits;
+						prob = p + SpecPos + rep0
+							- posSlot - 1;
+					} else {
+						numDirectBits -= kNumAlignBits;
+						do {
+							RC_NORMALIZE;
+							Range >>= 1;
+							rep0 <<= 1;
+							if (Code >= Range) {
+								Code -= Range;
+								rep0 |= 1;
+							}
+						} while (--numDirectBits != 0);
+						prob = p + Align;
+						rep0 <<= kNumAlignBits;
+						numDirectBits = kNumAlignBits;
+					}
+					{
+						int i = 1;
+						int mi = 1;
+						do {
+							CProb *prob3 = prob
+								+ mi;
+							RC_GET_BIT2(prob3, mi,
+								;, rep0 |= i);
+							i <<= 1;
+						} while (--numDirectBits != 0);
+					}
+				} else
+					rep0 = posSlot;
+				if (++rep0 == (UInt32)(0)) {
+					/* it's for stream version */
+					len = kLzmaStreamWasFinishedId;
+					break;
+				}
+			}
+
+			len += kMatchMinLen;
+			if (rep0 > nowPos)
+				return LZMA_RESULT_DATA_ERROR;
+
+
+			do {
+				previousByte = outStream[nowPos - rep0];
+				len--;
+				outStream[nowPos++] = previousByte;
+			} while (len != 0 && nowPos < outSize);
+		}
+	}
+	RC_NORMALIZE;
+
+
+	*inSizeProcessed = (SizeT)(Buffer - inStream);
+	*outSizeProcessed = nowPos;
+	return LZMA_RESULT_OK;
 }
diff --git a/src/lib/lzmadecode.h b/src/lib/lzmadecode.h
index 34c9f14..69f5b3d 100644
--- a/src/lib/lzmadecode.h
+++ b/src/lib/lzmadecode.h
@@ -38,30 +38,29 @@ typedef UInt32 SizeT;
 
 #define LZMA_PROPERTIES_SIZE 5
 
-typedef struct _CLzmaProperties
-{
-  int lc;
-  int lp;
-  int pb;
-}CLzmaProperties;
+typedef struct _CLzmaProperties {
+	int lc;
+	int lp;
+	int pb;
+} CLzmaProperties;
 
-int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
+int LzmaDecodeProperties(CLzmaProperties *propsRes,
+	const unsigned char *propsData, int size);
 
-#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
+#define LzmaGetNumProbs(Properties)                                     \
+	(LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc           \
+						+ (Properties)->lp)))
 
 #define kLzmaNeedInitId (-2)
 
-typedef struct _CLzmaDecoderState
-{
-  CLzmaProperties Properties;
-  CProb *Probs;
-
-
+typedef struct _CLzmaDecoderState {
+	CLzmaProperties Properties;
+	CProb *Probs;
 } CLzmaDecoderState;
 
 
 int LzmaDecode(CLzmaDecoderState *vs,
-    const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
-    unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
+	const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+	unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
 
 #endif
diff --git a/src/lib/memcmp.c b/src/lib/memcmp.c
index 46f13a4..89059a1 100644
--- a/src/lib/memcmp.c
+++ b/src/lib/memcmp.c
@@ -7,7 +7,7 @@ int memcmp(const void *src1, const void *src2, size_t bytes)
 	s1 = src1;
 	s2 = src2;
 	result = 0;
-	while((bytes > 0) && (result == 0)) {
+	while ((bytes > 0) && (result == 0)) {
 		result = *s1 - *s2;
 		bytes--;
 		s1++;
diff --git a/src/lib/memmove.c b/src/lib/memmove.c
index 241917c..fd75135 100644
--- a/src/lib/memmove.c
+++ b/src/lib/memmove.c
@@ -5,15 +5,13 @@ void *memmove(void *vdest, const void *vsrc, size_t count)
 	char *dest = vdest;
 
 	if (dest <= src) {
-		while (count--) {
+		while (count--)
 			*dest++ = *src++;
-		}
 	} else {
 		src  += count - 1;
 		dest += count - 1;
-		while(count--) {
+		while (count--)
 			*dest-- = *src--;
-		}
 	}
 	return vdest;
 }
diff --git a/src/lib/memrange.c b/src/lib/memrange.c
index 489b562..75e10b8 100644
--- a/src/lib/memrange.c
+++ b/src/lib/memrange.c
@@ -17,22 +17,22 @@
 #include <memrange.h>
 
 static inline void range_entry_link(struct range_entry **prev_ptr,
-                                    struct range_entry *r)
+					struct range_entry *r)
 {
 	r->next = *prev_ptr;
 	*prev_ptr = r;
 }
 
 static inline void range_entry_unlink(struct range_entry **prev_ptr,
-                                      struct range_entry *r)
+					struct range_entry *r)
 {
 	*prev_ptr = r->next;
 	r->next = NULL;
 }
 
 static inline void range_entry_unlink_and_free(struct memranges *ranges,
-                                               struct range_entry **prev_ptr,
-                                               struct range_entry *r)
+						struct range_entry **prev_ptr,
+						struct range_entry *r)
 {
 	range_entry_unlink(prev_ptr, r);
 	range_entry_link(&ranges->free_list, r);
@@ -54,7 +54,7 @@ static struct range_entry *alloc_range(struct memranges *ranges)
 
 static inline struct range_entry *
 range_list_add(struct memranges *ranges, struct range_entry **prev_ptr,
-               resource_t begin, resource_t end, unsigned long tag)
+		resource_t begin, resource_t end, unsigned long tag)
 {
 	struct range_entry *new_entry;
 
@@ -102,8 +102,8 @@ static void merge_neighbor_entries(struct memranges *ranges)
 }
 
 static void remove_memranges(struct memranges *ranges,
-                             resource_t begin, resource_t end,
-                             unsigned long unused)
+				resource_t begin, resource_t end,
+				unsigned long unused)
 {
 	struct range_entry *cur;
 	struct range_entry *next;
@@ -136,7 +136,7 @@ static void remove_memranges(struct memranges *ranges,
 			if (end >= cur->end) {
 				begin = cur->end + 1;
 				range_entry_unlink_and_free(ranges, prev_ptr,
-				                            cur);
+								cur);
 				continue;
 			}
 		}
@@ -152,7 +152,7 @@ static void remove_memranges(struct memranges *ranges,
 		/* Hole punched in middle of entry. */
 		if (begin > cur->begin && tmp_end < cur->end) {
 			range_list_add(ranges, &cur->next, end + 1, cur->end,
-			               cur->tag);
+					cur->tag);
 			cur->end = begin - 1;
 			break;
 		}
@@ -168,8 +168,8 @@ static void remove_memranges(struct memranges *ranges,
 }
 
 static void merge_add_memranges(struct memranges *ranges,
-                                   resource_t begin, resource_t end,
-                                   unsigned long tag)
+					resource_t begin, resource_t end,
+					unsigned long tag)
 {
 	struct range_entry *cur;
 	struct range_entry **prev_ptr;
@@ -202,7 +202,7 @@ static void merge_add_memranges(struct memranges *ranges,
 }
 
 void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
-                          unsigned long new_tag)
+				unsigned long new_tag)
 {
 	struct range_entry *r;
 
@@ -215,12 +215,12 @@ void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
 }
 
 typedef void (*range_action_t)(struct memranges *ranges,
-                               resource_t begin, resource_t end,
-                               unsigned long tag);
+				resource_t begin, resource_t end,
+				unsigned long tag);
 
 static void do_action(struct memranges *ranges,
-                      resource_t base, resource_t size, unsigned long tag,
-                      range_action_t action)
+			resource_t base, resource_t size, unsigned long tag,
+			range_action_t action)
 {
 	resource_t end;
 	resource_t begin;
@@ -238,13 +238,13 @@ static void do_action(struct memranges *ranges,
 }
 
 void memranges_create_hole(struct memranges *ranges,
-                              resource_t base, resource_t size)
+				resource_t base, resource_t size)
 {
 	do_action(ranges, base, size, -1, remove_memranges);
 }
 
 void memranges_insert(struct memranges *ranges,
-                      resource_t base, resource_t size, unsigned long tag)
+			resource_t base, resource_t size, unsigned long tag)
 {
 	do_action(ranges, base, size, tag, merge_add_memranges);
 }
@@ -267,9 +267,9 @@ static void collect_ranges(void *gp, struct device *dev, struct resource *res)
 }
 
 void memranges_add_resources_filter(struct memranges *ranges,
-                                    unsigned long mask, unsigned long match,
-                                    unsigned long tag,
-                                    memrange_filter_t filter)
+					unsigned long mask, unsigned long match,
+					unsigned long tag,
+					memrange_filter_t filter)
 {
 	struct collect_context context;
 
@@ -284,14 +284,14 @@ void memranges_add_resources_filter(struct memranges *ranges,
 }
 
 void memranges_add_resources(struct memranges *ranges,
-                             unsigned long mask, unsigned long match,
-                             unsigned long tag)
+				unsigned long mask, unsigned long match,
+				unsigned long tag)
 {
 	memranges_add_resources_filter(ranges, mask, match, tag, NULL);
 }
 
 void memranges_init_empty(struct memranges *ranges, struct range_entry *to_free,
-                          size_t num_free)
+				size_t num_free)
 {
 	size_t i;
 
@@ -303,8 +303,8 @@ void memranges_init_empty(struct memranges *ranges, struct range_entry *to_free,
 }
 
 void memranges_init(struct memranges *ranges,
-                    unsigned long mask, unsigned long match,
-                    unsigned long tag)
+			unsigned long mask, unsigned long match,
+			unsigned long tag)
 {
 	memranges_init_empty(ranges, NULL, 0);
 	memranges_add_resources(ranges, mask, match, tag);
@@ -314,12 +314,12 @@ void memranges_teardown(struct memranges *ranges)
 {
 	while (ranges->entries != NULL) {
 		range_entry_unlink_and_free(ranges, &ranges->entries,
-		                            ranges->entries);
+						ranges->entries);
 	}
 }
 
 void memranges_fill_holes_up_to(struct memranges *ranges,
-                                resource_t limit, unsigned long tag)
+					resource_t limit, unsigned long tag)
 {
 	struct range_entry *cur;
 	struct range_entry *prev;
@@ -341,7 +341,7 @@ void memranges_fill_holes_up_to(struct memranges *ranges,
 			if (end >= limit)
 				end = limit - 1;
 			range_list_add(ranges, &prev->next,
-			               range_entry_end(prev), end, tag);
+					range_entry_end(prev), end, tag);
 		}
 
 		prev = cur;
@@ -356,14 +356,14 @@ void memranges_fill_holes_up_to(struct memranges *ranges,
 	 * to be added to cover the range up to the limit. */
 	if (prev != NULL && range_entry_end(prev) < limit)
 		range_list_add(ranges, &prev->next, range_entry_end(prev),
-		               limit - 1, tag);
+				limit - 1, tag);
 
 	/* Merge all entries that were newly added. */
 	merge_neighbor_entries(ranges);
 }
 
 struct range_entry *memranges_next_entry(struct memranges *ranges,
-                                         const struct range_entry *r)
+					const struct range_entry *r)
 {
 	return r->next;
 }
diff --git a/src/lib/mocked_tlcl.c b/src/lib/mocked_tlcl.c
index 8dfcfab..86c232e 100644
--- a/src/lib/mocked_tlcl.c
+++ b/src/lib/mocked_tlcl.c
@@ -23,17 +23,20 @@
 #define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args)
 #endif
 
-uint32_t tlcl_lib_init(void) {
+uint32_t tlcl_lib_init(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_startup(void) {
+uint32_t tlcl_startup(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_resume(void) {
+uint32_t tlcl_resume(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
@@ -56,45 +59,51 @@ uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_write(uint32_t index, const void* data, uint32_t length)
+uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length)
 {
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_read(uint32_t index, void* data, uint32_t length)
+uint32_t tlcl_read(uint32_t index, void *data, uint32_t length)
 {
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
 
-uint32_t tlcl_assert_physical_presence(void) {
+uint32_t tlcl_assert_physical_presence(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_physical_presence_cmd_enable(void) {
+uint32_t tlcl_physical_presence_cmd_enable(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_finalize_physical_presence(void) {
+uint32_t tlcl_finalize_physical_presence(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_set_nv_locked(void) {
+uint32_t tlcl_set_nv_locked(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_force_clear(void) {
+uint32_t tlcl_force_clear(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_set_enable(void) {
+uint32_t tlcl_set_enable(void)
+{
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
@@ -105,14 +114,14 @@ uint32_t tlcl_set_deactivated(uint8_t flag)
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS* pflags)
+uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
 {
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_get_flags(uint8_t* disable, uint8_t* deactivated,
-                        uint8_t *nvlocked)
+uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated,
+			uint8_t *nvlocked)
 {
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
@@ -124,8 +133,8 @@ uint32_t tlcl_set_global_lock(void)
 	return TPM_E_NO_DEVICE;
 }
 
-uint32_t tlcl_extend(int pcr_num, const uint8_t* in_digest,
-                     uint8_t* out_digest)
+uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest,
+			uint8_t *out_digest)
 {
 	VBDEBUG("MOCK_TPM: %s\n", __func__);
 	return TPM_E_NO_DEVICE;
diff --git a/src/lib/primitive_memtest.c b/src/lib/primitive_memtest.c
index 6e58233..c699e89 100644
--- a/src/lib/primitive_memtest.c
+++ b/src/lib/primitive_memtest.c
@@ -25,7 +25,7 @@ int primitive_memtest(uintptr_t base, uintptr_t size)
 
 	printk(BIOS_SPEW, "Performing primitive memory test.\n");
 	printk(BIOS_SPEW, "DRAM start: 0x%08x, DRAM size: 0x%08x", base, size);
-	for(i = base; i < base + (size - 1) - sizeof(p); i += sizeof(p)) {
+	for (i = base; i < base + (size - 1) - sizeof(p); i += sizeof(p)) {
 		if (i % 0x100000 == 0) {
 			if ((i % 0x800000) == 0)
 				printk(BIOS_SPEW, "\n");
@@ -38,7 +38,7 @@ int primitive_memtest(uintptr_t base, uintptr_t size)
 	}
 
 	printk(BIOS_SPEW, "\n\nReading back DRAM content");
-	for(i = base; i < base + (size - 1) - sizeof(p); i += sizeof(p)) {
+	for (i = base; i < base + (size - 1) - sizeof(p); i += sizeof(p)) {
 		if (i % 0x100000 == 0) {
 			if ((i % 0x800000) == 0)
 				printk(BIOS_SPEW, "\n");
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c
index 58c1a8a..128869b 100644
--- a/src/lib/prog_loaders.c
+++ b/src/lib/prog_loaders.c
@@ -166,7 +166,6 @@ static struct prog global_payload =
 
 void __attribute__((weak)) mirror_payload(struct prog *payload)
 {
-	return;
 }
 
 void payload_load(void)
diff --git a/src/lib/ramtest.c b/src/lib/ramtest.c
index 6d12060..419d0eb 100644
--- a/src/lib/ramtest.c
+++ b/src/lib/ramtest.c
@@ -84,7 +84,7 @@ static int ram_bitset_nodie(unsigned long start)
 	uint8_t verbose = 0;
 
 	printk(BIOS_DEBUG, "DRAM bitset write: 0x%08lx\n", start);
-	for (idx=0; idx<0x400; idx+=4) {
+	for (idx = 0; idx < 0x400; idx += 4) {
 		test_pattern(idx, &addr, &value);
 		write_phys(start + addr, value);
 	}
@@ -94,7 +94,7 @@ static int ram_bitset_nodie(unsigned long start)
 
 	printk(BIOS_DEBUG, "DRAM bitset verify: 0x%08lx\n", start);
 	failures = 0;
-	for (idx=0; idx<0x400; idx+=4) {
+	for (idx = 0; idx < 0x400; idx += 4) {
 		test_pattern(idx, &addr, &value);
 		value2 = read_phys(start + addr);
 
@@ -120,9 +120,8 @@ static int ram_bitset_nodie(unsigned long start)
 		post_code(0xea);
 		printk(BIOS_DEBUG, "\nDRAM did _NOT_ verify!\n");
 		return 1;
-	} else {
-		printk(BIOS_DEBUG, "\nDRAM range verified.\n");
 	}
+	printk(BIOS_DEBUG, "\nDRAM range verified.\n");
 	return 0;
 }
 
@@ -162,7 +161,7 @@ int ram_check_noprint_nodie(unsigned long start, unsigned long stop)
 	unsigned short int idx;
 	unsigned char failed, failures;
 
-	for (idx=0; idx<0x400; idx+=4) {
+	for (idx = 0; idx < 0x400; idx += 4) {
 		test_pattern(idx, &addr, &value);
 		write_phys(start + addr, value);
 	}
@@ -171,7 +170,7 @@ int ram_check_noprint_nodie(unsigned long start, unsigned long stop)
 	phys_memory_barrier();
 
 	failures = 0;
-	for (idx=0; idx<0x400; idx+=4) {
+	for (idx = 0; idx < 0x400; idx += 4) {
 		test_pattern(idx, &addr, &value);
 		value2 = read_phys(start + addr);
 
@@ -189,19 +188,19 @@ static void __quick_ram_check(uintptr_t dst)
 	write_phys(dst, 0x55555555);
 	phys_memory_barrier();
 	if (read_phys(dst) != 0x55555555)
-		fail=1;
+		fail = 1;
 	write_phys(dst, 0xaaaaaaaa);
 	phys_memory_barrier();
 	if (read_phys(dst) != 0xaaaaaaaa)
-		fail=1;
+		fail = 1;
 	write_phys(dst, 0x00000000);
 	phys_memory_barrier();
 	if (read_phys(dst) != 0x00000000)
-		fail=1;
+		fail = 1;
 	write_phys(dst, 0xffffffff);
 	phys_memory_barrier();
 	if (read_phys(dst) != 0xffffffff)
-		fail=1;
+		fail = 1;
 
 	write_phys(dst, backup);
 	if (fail) {
diff --git a/src/lib/reg_script.c b/src/lib/reg_script.c
index 16efa36..78301dc 100644
--- a/src/lib/reg_script.c
+++ b/src/lib/reg_script.c
@@ -41,14 +41,14 @@
 #endif
 
 static inline void reg_script_set_dev(struct reg_script_context *ctx,
-                                      device_t dev)
+					device_t dev)
 {
 	ctx->dev = dev;
 	ctx->res = NULL;
 }
 
 static inline void reg_script_set_step(struct reg_script_context *ctx,
-                                       const struct reg_script *step)
+					const struct reg_script *step)
 {
 	ctx->step = step;
 }
@@ -192,8 +192,7 @@ static uint32_t reg_script_read_res(struct reg_script_context *ctx)
 		};
 		reg_script_set_step(ctx, &io_step);
 		val = reg_script_read_io(ctx);
-	}
-	else if (res->flags & IORESOURCE_MEM) {
+	} else if (res->flags & IORESOURCE_MEM) {
 		const struct reg_script mmio_step = {
 			.size = step->size,
 			.reg = res->base + step->reg,
@@ -223,8 +222,7 @@ static void reg_script_write_res(struct reg_script_context *ctx)
 		};
 		reg_script_set_step(ctx, &io_step);
 		reg_script_write_io(ctx);
-	}
-	else if (res->flags & IORESOURCE_MEM) {
+	} else if (res->flags & IORESOURCE_MEM) {
 		const struct reg_script mmio_step = {
 			.size = step->size,
 			.reg = res->base + step->reg,
@@ -399,7 +397,7 @@ static const struct reg_script_bus_entry
 {
 	extern const struct reg_script_bus_entry *_rsbe_init_begin[];
 	extern const struct reg_script_bus_entry *_ersbe_init_begin[];
-	const struct reg_script_bus_entry * const * bus;
+	const struct reg_script_bus_entry * const *bus;
 	size_t table_entries;
 	size_t i;
 
@@ -478,7 +476,7 @@ static uint64_t reg_script_read(struct reg_script_context *ctx)
 
 			/* Read from the platform specific bus */
 			bus = find_bus(step);
-			if (NULL != bus) {
+			if (bus != NULL) {
 				value = bus->reg_script_read(ctx);
 				break;
 			}
@@ -532,7 +530,7 @@ static void reg_script_write(struct reg_script_context *ctx)
 
 			/* Write to the platform specific bus */
 			bus = find_bus(step);
-			if (NULL != bus) {
+			if (bus != NULL) {
 				bus->reg_script_write(ctx);
 				break;
 			}
@@ -603,7 +601,7 @@ static void reg_script_rxw(struct reg_script_context *ctx)
  * as the previous one. That will run to completion and then move on to the
  * next step of the previous context. */
 static void reg_script_run_next(struct reg_script_context *ctx,
-                                const struct reg_script *step);
+				const struct reg_script *step);
 
 
 static void reg_script_run_step(struct reg_script_context *ctx,
@@ -670,7 +668,7 @@ static void reg_script_run_with_context(struct reg_script_context *ctx)
 }
 
 static void reg_script_run_next(struct reg_script_context *prev_ctx,
-                                const struct reg_script *step)
+				const struct reg_script *step)
 {
 	struct reg_script_context ctx;
 
diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c
index 7043157..3cb80f1 100644
--- a/src/lib/rmodule.c
+++ b/src/lib/rmodule.c
@@ -33,7 +33,7 @@ static inline int rmodule_is_loaded(const struct rmodule *module)
 
 /* Calculate a loaded program address based on the blob address. */
 static inline void *rmodule_load_addr(const struct rmodule *module,
-                                      uintptr_t blob_addr)
+					uintptr_t blob_addr)
 {
 	char *loc = module->location;
 	return &loc[blob_addr - module->header->module_link_start_address];
@@ -66,7 +66,7 @@ int rmodule_parse(void *ptr, struct rmodule *module)
 	/* The payload lives after the header. */
 	module->payload = &base[rhdr->payload_begin_offset];
 	module->payload_size = rhdr->payload_end_offset -
-	                       rhdr->payload_begin_offset;
+				rhdr->payload_begin_offset;
 	module->relocations = &base[rhdr->relocations_begin_offset];
 
 	return 0;
@@ -204,7 +204,7 @@ int rmodule_load(void *base, struct rmodule *module)
 }
 
 int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
-                        size_t *region_size, int *load_offset)
+			size_t *region_size, int *load_offset)
 {
 	/* region_alignment must be a power of 2. */
 	if (region_alignment & (region_alignment - 1))
@@ -270,7 +270,7 @@ int rmodule_stage_load(struct rmod_stage_load *rsl)
 
 	rmodule_offset =
 		rmodule_calc_region(DYN_CBMEM_ALIGN_SIZE,
-		                    stage.memlen, &region_size, &load_offset);
+				stage.memlen, &region_size, &load_offset);
 
 	stage_region = cbmem_add(rsl->cbmem_id, region_size);
 
diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c
index 162a034..5808dac 100644
--- a/src/lib/selfboot.c
+++ b/src/lib/selfboot.c
@@ -135,7 +135,7 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
 		return 0;
 
 	if (!arch_supports_bounce_buffer())
-		die ("bounce buffer not supported");
+		die("bounce buffer not supported");
 
 	start = seg->s_dstaddr;
 	middle = start + seg->s_filesz;
@@ -170,7 +170,8 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
 			/* compute the new value of start */
 			start = seg->s_dstaddr;
 
-			printk(BIOS_SPEW, "   early: [0x%016lx, 0x%016lx, 0x%016lx)\n",
+			printk(BIOS_SPEW,
+				"   early: [0x%016lx, 0x%016lx, 0x%016lx)\n",
 				new->s_dstaddr,
 				new->s_dstaddr + new->s_filesz,
 				new->s_dstaddr + new->s_memsz);
@@ -199,7 +200,8 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
 			/* Order by stream offset */
 			segment_insert_after(seg, new);
 
-			printk(BIOS_SPEW, "   late: [0x%016lx, 0x%016lx, 0x%016lx)\n",
+			printk(BIOS_SPEW,
+				"   late: [0x%016lx, 0x%016lx, 0x%016lx)\n",
 				new->s_dstaddr,
 				new->s_dstaddr + new->s_filesz,
 				new->s_dstaddr + new->s_memsz);
@@ -274,8 +276,10 @@ static int build_self_segment_list(
 				+ segment.offset;
 			new->s_filesz = segment.len;
 
-			printk(BIOS_DEBUG, "  New segment dstaddr 0x%lx memsize 0x%lx srcaddr 0x%lx filesize 0x%lx\n",
-				new->s_dstaddr, new->s_memsz, new->s_srcaddr, new->s_filesz);
+			printk(BIOS_DEBUG,
+				"  New segment dstaddr 0x%lx memsize 0x%lx srcaddr 0x%lx filesize 0x%lx\n",
+				new->s_dstaddr, new->s_memsz, new->s_srcaddr,
+				new->s_filesz);
 
 			/* Clean up the values */
 			if (new->s_filesz > new->s_memsz)  {
@@ -369,7 +373,7 @@ static int load_self_segments(struct segment *head, struct prog *payload,
 			return 0;
 	}
 
-	for(ptr = head->next; ptr != head; ptr = ptr->next) {
+	for (ptr = head->next; ptr != head; ptr = ptr->next) {
 		/*
 		 * Add segments to bootmem memory map before a bounce buffer is
 		 * allocated so that there aren't conflicts with the actual
@@ -391,20 +395,23 @@ static int load_self_segments(struct segment *head, struct prog *payload,
 		return 0;
 	}
 
-	for(ptr = head->next; ptr != head; ptr = ptr->next) {
+	for (ptr = head->next; ptr != head; ptr = ptr->next) {
 		unsigned char *dest, *src, *middle, *end;
 		size_t len, memsz;
-		printk(BIOS_DEBUG, "Loading Segment: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n",
+		printk(BIOS_DEBUG,
+			"Loading Segment: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n",
 			ptr->s_dstaddr, ptr->s_memsz, ptr->s_filesz);
 
-		/* Modify the segment to load onto the bounce_buffer if necessary.
+		/* Modify the segment to load onto the bounce_buffer if
+		 * necessary.
 		 */
 		if (relocate_segment(bounce_buffer, ptr)) {
 			ptr = (ptr->prev)->prev;
 			continue;
 		}
 
-		printk(BIOS_DEBUG, "Post relocation: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n",
+		printk(BIOS_DEBUG,
+			"Post relocation: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n",
 			ptr->s_dstaddr, ptr->s_memsz, ptr->s_filesz);
 
 		/* Compute the boundaries of the segment */
@@ -415,33 +422,35 @@ static int load_self_segments(struct segment *head, struct prog *payload,
 		end = dest + memsz;
 
 		/* Copy data from the initial buffer */
-		switch(ptr->compression) {
-			case CBFS_COMPRESS_LZMA: {
-				printk(BIOS_DEBUG, "using LZMA\n");
-				timestamp_add_now(TS_START_ULZMA);
-				len = ulzman(src, len, dest, memsz);
-				timestamp_add_now(TS_END_ULZMA);
-				if (!len) /* Decompression Error. */
-					return 0;
-				break;
-			}
-			case CBFS_COMPRESS_LZ4: {
-				printk(BIOS_DEBUG, "using LZ4\n");
-				timestamp_add_now(TS_START_ULZ4F);
-				len = ulz4fn(src, len, dest, memsz);
-				timestamp_add_now(TS_END_ULZ4F);
-				if (!len) /* Decompression Error. */
-					return 0;
-				break;
-			}
-			case CBFS_COMPRESS_NONE: {
-				printk(BIOS_DEBUG, "it's not compressed!\n");
-				memcpy(dest, src, len);
-				break;
-			}
-			default:
-				printk(BIOS_INFO,  "CBFS:  Unknown compression type %d\n", ptr->compression);
-				return -1;
+		switch (ptr->compression) {
+		case CBFS_COMPRESS_LZMA: {
+			printk(BIOS_DEBUG, "using LZMA\n");
+			timestamp_add_now(TS_START_ULZMA);
+			len = ulzman(src, len, dest, memsz);
+			timestamp_add_now(TS_END_ULZMA);
+			if (!len) /* Decompression Error. */
+				return 0;
+			break;
+		}
+		case CBFS_COMPRESS_LZ4: {
+			printk(BIOS_DEBUG, "using LZ4\n");
+			timestamp_add_now(TS_START_ULZ4F);
+			len = ulz4fn(src, len, dest, memsz);
+			timestamp_add_now(TS_END_ULZ4F);
+			if (!len) /* Decompression Error. */
+				return 0;
+			break;
+		}
+		case CBFS_COMPRESS_NONE: {
+			printk(BIOS_DEBUG, "it's not compressed!\n");
+			memcpy(dest, src, len);
+			break;
+		}
+		default:
+			printk(BIOS_INFO,
+				"CBFS:  Unknown compression type %d\n",
+				ptr->compression);
+			return -1;
 		}
 		/* Calculate middle after any changes to len. */
 		middle = dest + len;
@@ -453,29 +462,43 @@ static int load_self_segments(struct segment *head, struct prog *payload,
 
 		/* Zero the extra bytes between middle & end */
 		if (middle < end) {
-			printk(BIOS_DEBUG, "Clearing Segment: addr: 0x%016lx memsz: 0x%016lx\n",
-				(unsigned long)middle, (unsigned long)(end - middle));
+			printk(BIOS_DEBUG,
+			   "Clearing Segment: addr: 0x%016lx memsz: 0x%016lx\n",
+				(unsigned long)middle,
+				(unsigned long)(end - middle));
 
 			/* Zero the extra bytes */
 			memset(middle, 0, end - middle);
 		}
 
-		/* Copy the data that's outside the area that shadows ramstage */
-		printk(BIOS_DEBUG, "dest %p, end %p, bouncebuffer %lx\n", dest, end, bounce_buffer);
+		/* Copy the data that's outside the area that shadows
+		 * ramstage
+		 */
+		printk(BIOS_DEBUG, "dest %p, end %p, bouncebuffer %lx\n", dest,
+			end, bounce_buffer);
 		if ((unsigned long)end > bounce_buffer) {
 			if ((unsigned long)dest < bounce_buffer) {
 				unsigned char *from = dest;
-				unsigned char *to = (unsigned char*)(lb_start-(bounce_buffer-(unsigned long)dest));
-				unsigned long amount = bounce_buffer-(unsigned long)dest;
-				printk(BIOS_DEBUG, "move prefix around: from %p, to %p, amount: %lx\n", from, to, amount);
+				unsigned char *to = (unsigned char *)(lb_start -
+					(bounce_buffer - (unsigned long)dest));
+				unsigned long amount = bounce_buffer -
+					(unsigned long)dest;
+				printk(BIOS_DEBUG,
+					"move prefix around: from %p, to %p, amount: %lx\n",
+					from, to, amount);
 				memcpy(to, from, amount);
 			}
-			if ((unsigned long)end > bounce_buffer + (lb_end - lb_start)) {
-				unsigned long from = bounce_buffer + (lb_end - lb_start);
+			if ((unsigned long)end > bounce_buffer + (lb_end -
+				lb_start)) {
+				unsigned long from = bounce_buffer + (lb_end -
+					lb_start);
 				unsigned long to = lb_end;
-				unsigned long amount = (unsigned long)end - from;
-				printk(BIOS_DEBUG, "move suffix around: from %lx, to %lx, amount: %lx\n", from, to, amount);
-				memcpy((char*)to, (char*)from, amount);
+				unsigned long amount = (unsigned long)end -
+					from;
+				printk(BIOS_DEBUG,
+					"move suffix around: from %lx, to %lx, amount: %lx\n",
+					from, to, amount);
+				memcpy((char *)to, (char *)from, amount);
 			}
 		}
 
diff --git a/src/lib/spd_bin.c b/src/lib/spd_bin.c
index 8f358bb..1e03698 100644
--- a/src/lib/spd_bin.c
+++ b/src/lib/spd_bin.c
@@ -185,26 +185,28 @@ int read_ddr3_spd_from_cbfs(u8 *buf, int idx)
 	if (!spd_file || spd_file_len < min_len)
 		return -1;
 
-	memcpy(buf, spd_file + (idx * CONFIG_DIMM_SPD_SIZE), CONFIG_DIMM_SPD_SIZE);
+	memcpy(buf, spd_file + (idx * CONFIG_DIMM_SPD_SIZE),
+		CONFIG_DIMM_SPD_SIZE);
 
 	u16 crc = spd_ddr3_calc_crc(buf, CONFIG_DIMM_SPD_SIZE);
 
 	if (((buf[SPD_CRC_LO] == 0) && (buf[SPD_CRC_HI] == 0))
 	 || (buf[SPD_CRC_LO] != (crc & 0xff))
 	 || (buf[SPD_CRC_HI] != (crc >> 8))) {
-		printk(BIOS_WARNING, "SPD CRC %02x%02x is invalid, should be %04x\n",
+		printk(BIOS_WARNING,
+			"SPD CRC %02x%02x is invalid, should be %04x\n",
 			buf[SPD_CRC_HI], buf[SPD_CRC_LO], crc);
 		buf[SPD_CRC_LO] = crc & 0xff;
 		buf[SPD_CRC_HI] = crc >> 8;
 		u16 i;
 		printk(BIOS_WARNING, "\nDisplay the SPD");
 		for (i = 0; i < CONFIG_DIMM_SPD_SIZE; i++) {
-			if((i % 16) == 0x00)
+			if ((i % 16) == 0x00)
 				printk(BIOS_WARNING, "\n%02x:  ", i);
 			printk(BIOS_WARNING, "%02x ", buf[i]);
 		}
 		printk(BIOS_WARNING, "\n");
-	 }
-	 return 0;
+	}
+	return 0;
 }
 #endif
diff --git a/src/lib/stack.c b/src/lib/stack.c
index bebeea2..7aafa8f 100644
--- a/src/lib/stack.c
+++ b/src/lib/stack.c
@@ -18,7 +18,8 @@ it with the version available from LANL.
  */
 /* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
  * rminnich at lanl.gov
- * Copyright (C) 2015 Timothy Pearson <tpearson at raptorengineeringinc.com>, Raptor Engineering
+ * Copyright (C) 2015 Timothy Pearson <tpearson at raptorengineeringinc.com>,
+ * Raptor Engineering
  */
 
 #include <assert.h>
@@ -33,7 +34,7 @@ int checkstack(void *top_of_stack, int core)
 	int i;
 	u32 *stack = (u32 *) (top_of_stack - stack_size);
 
-	if (stack[0] != 0xDEADBEEF){
+	if (stack[0] != 0xDEADBEEF) {
 		printk(BIOS_ERR, "Stack overrun on CPU%d (address %p overwritten). "
 			"Increase stack from current %zu bytes\n",
 			core, stack, stack_size);
@@ -41,7 +42,7 @@ int checkstack(void *top_of_stack, int core)
 		return -1;
 	}
 
-	for(i = 1; i < stack_size/sizeof(stack[0]); i++){
+	for (i = 1; i < stack_size/sizeof(stack[0]); i++) {
 		if (stack[i] == 0xDEADBEEF)
 			continue;
 		printk(BIOS_SPEW, "CPU%d: stack: %p - %p, ",
@@ -54,5 +55,4 @@ int checkstack(void *top_of_stack, int core)
 	}
 
 	return 0;
-
 }
diff --git a/src/lib/thread.c b/src/lib/thread.c
index 75d0cfc..f3cbd91 100644
--- a/src/lib/thread.c
+++ b/src/lib/thread.c
@@ -121,9 +121,8 @@ static void idle_thread(void *unused)
 {
 	/* This thread never voluntarily yields. */
 	thread_prevent_coop();
-	while (1) {
+	while (1)
 		timers_run();
-	}
 }
 
 static void schedule(struct thread *t)
@@ -187,8 +186,8 @@ static void asmlinkage call_wrapper_block_state(void *arg)
 /* Prepare a thread so that it starts by executing thread_entry(thread_arg).
  * Within thread_entry() it will call func(arg). */
 static void prepare_thread(struct thread *t, void *func, void *arg,
-                           void asmlinkage (*thread_entry)(void *),
-                           void *thread_arg)
+				asmlinkage void (*thread_entry)(void *),
+				void *thread_arg)
 {
 	/* Stash the function and argument to run. */
 	t->entry = func;
@@ -214,9 +213,8 @@ static void idle_thread_init(void)
 
 	t = get_free_thread();
 
-	if (t == NULL) {
+	if (t == NULL)
 		die("No threads available for idle thread!\n");
-	}
 
 	/* Queue idle thread to run once all other threads have yielded. */
 	prepare_thread(t, idle_thread, NULL, call_wrapper, NULL);
@@ -228,7 +226,8 @@ static void idle_thread_init(void)
 /* Don't inline this function so the timeout_callback won't have its storage
  * space on the stack cleaned up before the call to schedule(). */
 static int __attribute__((noinline))
-thread_yield_timed_callback(struct timeout_callback *tocb, unsigned microsecs)
+thread_yield_timed_callback(struct timeout_callback *tocb,
+	unsigned int microsecs)
 {
 	tocb->priv = current_thread();
 	tocb->callback = thread_resume_from_timeout;
@@ -307,7 +306,7 @@ int thread_run(void (*func)(void *), void *arg)
 }
 
 int thread_run_until(void (*func)(void *), void *arg,
-                     boot_state_t state, boot_state_sequence_t seq)
+			boot_state_t state, boot_state_sequence_t seq)
 {
 	struct thread *current;
 	struct thread *t;
@@ -337,7 +336,7 @@ int thread_run_until(void (*func)(void *), void *arg,
 	return 0;
 }
 
-int thread_yield_microseconds(unsigned microsecs)
+int thread_yield_microseconds(unsigned int microsecs)
 {
 	struct thread *current;
 	struct timeout_callback tocb;
diff --git a/src/lib/timer.c b/src/lib/timer.c
index da24067..58d32ee 100644
--- a/src/lib/timer.c
+++ b/src/lib/timer.c
@@ -18,9 +18,9 @@
 #include <delay.h>
 #include <thread.h>
 
-__attribute__((weak)) void init_timer() { /* do nothing */ }
+__attribute__((weak)) void init_timer(void) { /* do nothing */ }
 
-void udelay(unsigned usec)
+void udelay(unsigned int usec)
 {
 	struct stopwatch sw;
 
diff --git a/src/lib/timer_queue.c b/src/lib/timer_queue.c
index fe3e8b5..06872a8 100644
--- a/src/lib/timer_queue.c
+++ b/src/lib/timer_queue.c
@@ -49,7 +49,7 @@ static inline struct timeout_callback *timer_queue_head(struct timer_queue *tq)
 }
 
 static int timer_queue_insert(struct timer_queue *tq,
-                              struct timeout_callback *tocb)
+				struct timeout_callback *tocb)
 {
 	int index;
 
@@ -99,7 +99,7 @@ static int timer_queue_min_child_index(struct timer_queue *tq, int index)
 		return left_child_index;
 
 	if (mono_time_cmp(&tq->queue[left_child_index]->expiration,
-	                 &tq->queue[right_child_index]->expiration) < 0) {
+			&tq->queue[right_child_index]->expiration) < 0) {
 		return left_child_index;
 	}
 	return right_child_index;
@@ -165,7 +165,7 @@ int timer_sched_callback(struct timeout_callback *tocb, unsigned long us)
 {
 	struct mono_time current_time;
 
-	if ((long)us< 0)
+	if ((long)us < 0)
 		return -1;
 
 	timer_monotonic_get(&current_time);
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index 2f2a5d8..5f84cf4 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -92,7 +92,7 @@ static struct timestamp_cache *timestamp_cache_get(void)
 
 static struct timestamp_table *timestamp_alloc_cbmem_table(void)
 {
-	struct timestamp_table* tst;
+	struct timestamp_table *tst;
 
 	tst = cbmem_add(CBMEM_ID_TIMESTAMP,
 			sizeof(struct timestamp_table) +
diff --git a/src/lib/tlcl.c b/src/lib/tlcl.c
index 0a4706b..e3620ea 100644
--- a/src/lib/tlcl.c
+++ b/src/lib/tlcl.c
@@ -47,41 +47,46 @@ static int tpm_send_receive(const uint8_t *request,
 }
 
 /* Sets the size field of a TPM command. */
-static inline void set_tpm_command_size(uint8_t* buffer, uint32_t size) {
+static inline void set_tpm_command_size(uint8_t *buffer, uint32_t size)
+{
 	to_tpm_uint32(buffer + sizeof(uint16_t), size);
 }
 
 /* Gets the size field of a TPM command. */
 __attribute__((unused))
-static inline int tpm_command_size(const uint8_t* buffer) {
+static inline int tpm_command_size(const uint8_t *buffer)
+{
 	uint32_t size;
 	from_tpm_uint32(buffer + sizeof(uint16_t), &size);
 	return (int) size;
 }
 
 /* Gets the code field of a TPM command. */
-static inline int tpm_command_code(const uint8_t* buffer) {
+static inline int tpm_command_code(const uint8_t *buffer)
+{
 	uint32_t code;
 	from_tpm_uint32(buffer + sizeof(uint16_t) + sizeof(uint32_t), &code);
 	return code;
 }
 
 /* Gets the return code field of a TPM result. */
-static inline int tpm_return_code(const uint8_t* buffer) {
+static inline int tpm_return_code(const uint8_t *buffer)
+{
 	return tpm_command_code(buffer);
 }
 
 /* Like TlclSendReceive below, but do not retry if NEEDS_SELFTEST or
  * DOING_SELFTEST errors are returned.
  */
-static uint32_t tlcl_send_receive_no_retry(const uint8_t* request,
-                                           uint8_t* response, int max_length) {
+static uint32_t tlcl_send_receive_no_retry(const uint8_t *request,
+					uint8_t *response, int max_length)
+{
 	uint32_t response_length = max_length;
 	uint32_t result;
 
 	result = tpm_send_receive(request, tpm_command_size(request),
 					response, &response_length);
-	if (0 != result) {
+	if (result != 0) {
 		/* Communication with TPM failed, so response is garbage */
 		VBDEBUG("TPM: command 0x%x send/receive failed: 0x%x\n",
 			tpm_command_code(request), result);
@@ -103,8 +108,9 @@ return result;
 
 /* Sends a TPM command and gets a response.  Returns 0 if success or the TPM
  * error code if error. Waits for the self test to complete if needed. */
-uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
-			   int max_length) {
+uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response,
+				int max_length)
+{
 	uint32_t result = tlcl_send_receive_no_retry(request, response,
 						     max_length);
 	/* If the command fails because the self test has not completed, try it
@@ -116,7 +122,7 @@ uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
 #if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE)
 		/* Retry only once */
 		result = tlcl_send_receive_no_retry(request, response,
-		                                    max_length);
+							max_length);
 #else
 		/* This needs serious testing. The TPM specification says: "iii.
 		 * The caller MUST wait for the actions of TPM_ContinueSelfTest
@@ -125,7 +131,7 @@ uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
 		 * actions have completed other than trying again? */
 		do {
 			result = tlcl_send_receive_no_retry(request, response,
-			                                    max_length);
+								max_length);
 		} while (result == TPM_E_DOING_SELFTEST);
 #endif
 	}
@@ -133,7 +139,8 @@ uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
 }
 
 /* Sends a command and returns the error code. */
-static uint32_t send(const uint8_t* command) {
+static uint32_t send(const uint8_t *command)
+{
 	uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
 	return tlcl_send_receive(command, response, sizeof(response));
 }
@@ -142,7 +149,8 @@ static uint32_t send(const uint8_t* command) {
 
 static uint8_t tlcl_init_done CAR_GLOBAL;
 
-uint32_t tlcl_lib_init(void) {
+uint32_t tlcl_lib_init(void)
+{
 	uint8_t done = car_get_var(tlcl_init_done);
 	if (done)
 		return VB2_SUCCESS;
@@ -157,14 +165,16 @@ uint32_t tlcl_lib_init(void) {
 	return VB2_SUCCESS;
 }
 
-uint32_t tlcl_startup(void) {
+uint32_t tlcl_startup(void)
+{
 	VBDEBUG("TPM: Startup\n");
 	return send(tpm_startup_cmd.buffer);
 }
 
-uint32_t tlcl_resume(void) {
-  VBDEBUG("TPM: Resume\n");
-  return send(tpm_resume_cmd.buffer);
+uint32_t tlcl_resume(void)
+{
+	VBDEBUG("TPM: Resume\n");
+	return send(tpm_resume_cmd.buffer);
 }
 
 uint32_t tlcl_self_test_full(void)
@@ -179,7 +189,7 @@ uint32_t tlcl_continue_self_test(void)
 	VBDEBUG("TPM: Continue self test\n");
 	/* Call the No Retry version of SendReceive to avoid recursion. */
 	return tlcl_send_receive_no_retry(tpm_continueselftest_cmd.buffer,
-	                                  response, sizeof(response));
+						response, sizeof(response));
 }
 
 uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
@@ -193,7 +203,7 @@ uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
 	return send(cmd.buffer);
 }
 
-uint32_t tlcl_write(uint32_t index, const void* data, uint32_t length)
+uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length)
 {
 	struct s_tpm_nv_write_cmd cmd;
 	uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
@@ -212,7 +222,7 @@ uint32_t tlcl_write(uint32_t index, const void* data, uint32_t length)
 	return tlcl_send_receive(cmd.buffer, response, sizeof(response));
 }
 
-uint32_t tlcl_read(uint32_t index, void* data, uint32_t length)
+uint32_t tlcl_read(uint32_t index, void *data, uint32_t length)
 {
 	struct s_tpm_nv_read_cmd cmd;
 	uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
@@ -226,7 +236,7 @@ uint32_t tlcl_read(uint32_t index, void* data, uint32_t length)
 
 	result = tlcl_send_receive(cmd.buffer, response, sizeof(response));
 	if (result == TPM_SUCCESS && length > 0) {
-		uint8_t* nv_read_cursor = response + kTpmResponseHeaderLength;
+		uint8_t *nv_read_cursor = response + kTpmResponseHeaderLength;
 		from_tpm_uint32(nv_read_cursor, &result_length);
 		nv_read_cursor += sizeof(uint32_t);
 		memcpy(data, nv_read_cursor, result_length);
@@ -236,32 +246,38 @@ uint32_t tlcl_read(uint32_t index, void* data, uint32_t length)
 }
 
 
-uint32_t tlcl_assert_physical_presence(void) {
+uint32_t tlcl_assert_physical_presence(void)
+{
 	VBDEBUG("TPM: Asserting physical presence\n");
 	return send(tpm_ppassert_cmd.buffer);
 }
 
-uint32_t tlcl_physical_presence_cmd_enable(void) {
+uint32_t tlcl_physical_presence_cmd_enable(void)
+{
 	VBDEBUG("TPM: Enable the physical presence command\n");
 	return send(tpm_ppenable_cmd.buffer);
 }
 
-uint32_t tlcl_finalize_physical_presence(void) {
+uint32_t tlcl_finalize_physical_presence(void)
+{
 	VBDEBUG("TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n");
 	return send(tpm_finalizepp_cmd.buffer);
 }
 
-uint32_t tlcl_set_nv_locked(void) {
+uint32_t tlcl_set_nv_locked(void)
+{
 	VBDEBUG("TPM: Set NV locked\n");
 	return tlcl_define_space(TPM_NV_INDEX_LOCK, 0, 0);
 }
 
-uint32_t tlcl_force_clear(void) {
+uint32_t tlcl_force_clear(void)
+{
 	VBDEBUG("TPM: Force clear\n");
 	return send(tpm_forceclear_cmd.buffer);
 }
 
-uint32_t tlcl_set_enable(void) {
+uint32_t tlcl_set_enable(void)
+{
 	VBDEBUG("TPM: Enabling TPM\n");
 	return send(tpm_physicalenable_cmd.buffer);
 }
@@ -275,12 +291,12 @@ uint32_t tlcl_set_deactivated(uint8_t flag)
 	return send(cmd.buffer);
 }
 
-uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS* pflags)
+uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
 {
 	uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
 	uint32_t size;
 	uint32_t result = tlcl_send_receive(tpm_getflags_cmd.buffer, response,
-	                                    sizeof(response));
+						sizeof(response));
 	if (result != TPM_SUCCESS)
 		return result;
 	from_tpm_uint32(response + kTpmResponseHeaderLength, &size);
@@ -290,8 +306,8 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS* pflags)
 	return result;
 }
 
-uint32_t tlcl_get_flags(uint8_t* disable, uint8_t* deactivated,
-                        uint8_t *nvlocked)
+uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated,
+			uint8_t *nvlocked)
 {
 	TPM_PERMANENT_FLAGS pflags;
 	uint32_t result = tlcl_get_permanent_flags(&pflags);
@@ -312,11 +328,11 @@ uint32_t tlcl_set_global_lock(void)
 {
 	uint32_t x;
 	VBDEBUG("TPM: Set global lock\n");
-	return tlcl_write(TPM_NV_INDEX0, (uint8_t*) &x, 0);
+	return tlcl_write(TPM_NV_INDEX0, (uint8_t *)&x, 0);
 }
 
-uint32_t tlcl_extend(int pcr_num, const uint8_t* in_digest,
-                     uint8_t* out_digest)
+uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest,
+			uint8_t *out_digest)
 {
 	struct s_tpm_extend_cmd cmd;
 	uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
diff --git a/src/lib/tlcl_internal.h b/src/lib/tlcl_internal.h
index 8261b0d..f6c5014 100644
--- a/src/lib/tlcl_internal.h
+++ b/src/lib/tlcl_internal.h
@@ -16,14 +16,14 @@
 #define kEncAuthLength 20
 #define kPcrDigestLength 20
 
-
 /*
  * Conversion functions.  to_tpm_TYPE puts a value of type TYPE into a TPM
  * command buffer. from_tpm_TYPE gets a value of type TYPE from a TPM command
  * buffer into a variable.
  */
 __attribute__((unused))
-static inline void to_tpm_uint32(uint8_t *buffer, uint32_t x) {
+static inline void to_tpm_uint32(uint8_t *buffer, uint32_t x)
+{
 	buffer[0] = (uint8_t)(x >> 24);
 	buffer[1] = (uint8_t)((x >> 16) & 0xff);
 	buffer[2] = (uint8_t)((x >> 8) & 0xff);
@@ -34,7 +34,8 @@ static inline void to_tpm_uint32(uint8_t *buffer, uint32_t x) {
  * See comment for above function.
  */
 __attribute__((unused))
-static inline void from_tpm_uint32(const uint8_t *buffer, uint32_t *x) {
+static inline void from_tpm_uint32(const uint8_t *buffer, uint32_t *x)
+{
 	*x = ((buffer[0] << 24) |
 	      (buffer[1] << 16) |
 	      (buffer[2] << 8) |
@@ -45,7 +46,8 @@ static inline void from_tpm_uint32(const uint8_t *buffer, uint32_t *x) {
  * See comment for above function.
  */
 __attribute__((unused))
-static inline void to_tpm_uint16(uint8_t *buffer, uint16_t x) {
+static inline void to_tpm_uint16(uint8_t *buffer, uint16_t x)
+{
 	buffer[0] = (uint8_t)(x >> 8);
 	buffer[1] = (uint8_t)(x & 0xff);
 }
@@ -54,7 +56,8 @@ static inline void to_tpm_uint16(uint8_t *buffer, uint16_t x) {
  * See comment for above function.
  */
 __attribute__((unused))
-static inline void from_tpm_uint16(const uint8_t *buffer, uint16_t *x) {
+static inline void from_tpm_uint16(const uint8_t *buffer, uint16_t *x)
+{
 	*x = (buffer[0] << 8) | buffer[1];
 }
 
diff --git a/src/lib/tlcl_structures.h b/src/lib/tlcl_structures.h
index 36c1bb9..5a725bd 100644
--- a/src/lib/tlcl_structures.h
+++ b/src/lib/tlcl_structures.h
@@ -1,138 +1,180 @@
 /* This file is automatically generated */
 
-const struct s_tpm_extend_cmd{
-  uint8_t buffer[34];
-  uint16_t pcrNum;
-  uint16_t inDigest;
-} tpm_extend_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14, },
-10, 14, };
+const struct s_tpm_extend_cmd {
+	uint8_t buffer[34];
+	uint16_t pcrNum;
+	uint16_t inDigest;
+} tpm_extend_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14, },
+	10, 14,
+};
 
-const struct s_tpm_get_random_cmd{
-  uint8_t buffer[14];
-  uint16_t bytesRequested;
-} tpm_get_random_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x46, },
-10, };
+const struct s_tpm_get_random_cmd {
+	uint8_t buffer[14];
+	uint16_t bytesRequested;
+} tpm_get_random_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x46, },
+	10,
+};
 
-const struct s_tpm_getownership_cmd{
-  uint8_t buffer[22];
-} tpm_getownership_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x11, },
+const struct s_tpm_getownership_cmd {
+	uint8_t buffer[22];
+} tpm_getownership_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0,
+	0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x11, },
 };
 
-const struct s_tpm_getpermissions_cmd{
-  uint8_t buffer[22];
-  uint16_t index;
-} tpm_getpermissions_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x4, },
-18, };
+const struct s_tpm_getpermissions_cmd {
+	uint8_t buffer[22];
+	uint16_t index;
+} tpm_getpermissions_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0,
+	0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x4, },
+	18,
+};
 
-const struct s_tpm_getstclearflags_cmd{
-  uint8_t buffer[22];
-} tpm_getstclearflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x9, },
+const struct s_tpm_getstclearflags_cmd {
+	uint8_t buffer[22];
+} tpm_getstclearflags_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0,
+	0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x9, },
 };
 
-const struct s_tpm_getflags_cmd{
-  uint8_t buffer[22];
-} tpm_getflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x8, },
+const struct s_tpm_getflags_cmd {
+	uint8_t buffer[22];
+} tpm_getflags_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0,
+	0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x8, },
 };
 
-const struct s_tpm_physicalsetdeactivated_cmd{
-  uint8_t buffer[11];
-  uint16_t deactivated;
-} tpm_physicalsetdeactivated_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72, },
-10, };
+const struct s_tpm_physicalsetdeactivated_cmd {
+	uint8_t buffer[11];
+	uint16_t deactivated;
+} tpm_physicalsetdeactivated_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72, },
+	10,
+};
 
-const struct s_tpm_physicalenable_cmd{
-  uint8_t buffer[10];
-} tpm_physicalenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f, },
+const struct s_tpm_physicalenable_cmd {
+	uint8_t buffer[10];
+} tpm_physicalenable_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f, },
 };
 
-const struct s_tpm_physicaldisable_cmd{
-  uint8_t buffer[10];
-} tpm_physicaldisable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70, },
+const struct s_tpm_physicaldisable_cmd {
+	uint8_t buffer[10];
+} tpm_physicaldisable_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70, },
 };
 
-const struct s_tpm_forceclear_cmd{
-  uint8_t buffer[10];
-} tpm_forceclear_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d, },
+const struct s_tpm_forceclear_cmd {
+	uint8_t buffer[10];
+} tpm_forceclear_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d, },
 };
 
-const struct s_tpm_readpubek_cmd{
-  uint8_t buffer[30];
-} tpm_readpubek_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c, },
+const struct s_tpm_readpubek_cmd {
+	uint8_t buffer[30];
+} tpm_readpubek_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c, },
 };
 
-const struct s_tpm_continueselftest_cmd{
-  uint8_t buffer[10];
-} tpm_continueselftest_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53, },
+const struct s_tpm_continueselftest_cmd {
+	uint8_t buffer[10];
+} tpm_continueselftest_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53, },
 };
 
-const struct s_tpm_selftestfull_cmd{
-  uint8_t buffer[10];
-} tpm_selftestfull_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50, },
+const struct s_tpm_selftestfull_cmd {
+	uint8_t buffer[10];
+} tpm_selftestfull_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50, },
 };
 
-const struct s_tpm_resume_cmd{
-  uint8_t buffer[12];
-} tpm_resume_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x2, },
+const struct s_tpm_resume_cmd {
+	uint8_t buffer[12];
+} tpm_resume_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x2, },
 };
 
-const struct s_tpm_savestate_cmd{
-  uint8_t buffer[10];
-} tpm_savestate_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x98, },
+const struct s_tpm_savestate_cmd {
+	uint8_t buffer[10];
+} tpm_savestate_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x98, },
 };
 
-const struct s_tpm_startup_cmd{
-  uint8_t buffer[12];
-} tpm_startup_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x1, },
+const struct s_tpm_startup_cmd {
+	uint8_t buffer[12];
+} tpm_startup_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x1, },
 };
 
-const struct s_tpm_finalizepp_cmd{
-  uint8_t buffer[12];
-} tpm_finalizepp_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0, },
+const struct s_tpm_finalizepp_cmd {
+	uint8_t buffer[12];
+} tpm_finalizepp_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0, },
 };
 
-const struct s_tpm_pplock_cmd{
-  uint8_t buffer[12];
-} tpm_pplock_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x4, },
+const struct s_tpm_pplock_cmd {
+	uint8_t buffer[12];
+} tpm_pplock_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x4, },
 };
 
-const struct s_tpm_ppenable_cmd{
-  uint8_t buffer[12];
-} tpm_ppenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x20, },
+const struct s_tpm_ppenable_cmd {
+	uint8_t buffer[12];
+} tpm_ppenable_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x20, },
 };
 
-const struct s_tpm_ppassert_cmd{
-  uint8_t buffer[12];
-} tpm_ppassert_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x8, },
+const struct s_tpm_ppassert_cmd {
+	uint8_t buffer[12];
+} tpm_ppassert_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x8, },
 };
 
-const struct s_tpm_pcr_read_cmd{
-  uint8_t buffer[14];
-  uint16_t pcrNum;
+const struct s_tpm_pcr_read_cmd {
+	uint8_t buffer[14];
+	uint16_t pcrNum;
 } tpm_pcr_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15, },
-10, };
-
-const struct s_tpm_nv_read_cmd{
-  uint8_t buffer[22];
-  uint16_t index;
-  uint16_t length;
-} tpm_nv_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf, },
-10, 18, };
-
-const struct s_tpm_nv_write_cmd{
-  uint8_t buffer[256];
-  uint16_t index;
-  uint16_t length;
-  uint16_t data;
-} tpm_nv_write_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd, },
-10, 18, 22, };
-
-const struct s_tpm_nv_definespace_cmd{
-  uint8_t buffer[101];
-  uint16_t index;
-  uint16_t perm;
-  uint16_t size;
-} tpm_nv_definespace_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0xcc, 0x0, 0x18, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x17, },
-12, 70, 77, };
+	10,
+};
+
+const struct s_tpm_nv_read_cmd {
+	uint8_t buffer[22];
+	uint16_t index;
+	uint16_t length;
+} tpm_nv_read_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf, },
+	10, 18,
+};
+
+const struct s_tpm_nv_write_cmd {
+	uint8_t buffer[256];
+	uint16_t index;
+	uint16_t length;
+	uint16_t data;
+} tpm_nv_write_cmd = {
+	{0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd, },
+	10, 18, 22,
+};
+
+const struct s_tpm_nv_definespace_cmd {
+	uint8_t buffer[101];
+	uint16_t index;
+	uint16_t perm;
+	uint16_t size;
+} tpm_nv_definespace_cmd = {
+	{0,    0xc1, 0,    0,    0,    0x65, 0,    0,    0,    0xcc,
+	 0,    0x18, 0,    0,    0,    0,    0,    3,    0,    0,
+	 0,    0x1f, 0,    0,    0,    0,    0,    0,    0,    0,
+	 0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+	 0,    0,    0,    3,    0,    0,    0, 0x1f,    0,    0,
+	 0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+	 0,    0,    0,    0,    0,    0,    0,    0,    0,    0x17,
+	},
+	12, 70, 77,
+};
 
 const int kWriteInfoLength = 12;
 const int kNvDataPublicPermissionsOffset = 60;
diff --git a/src/lib/tpm2_tlcl.c b/src/lib/tpm2_tlcl.c
index 6c0cd6e..5300262 100644
--- a/src/lib/tpm2_tlcl.c
+++ b/src/lib/tpm2_tlcl.c
@@ -347,7 +347,8 @@ uint32_t tlcl_define_space(uint32_t space_index, size_t space_size)
 		 * value has been extended from default.
 		 */
 		nvds_cmd.publicInfo.authPolicy.t.buffer = pcr0_unchanged_policy;
-		nvds_cmd.publicInfo.authPolicy.t.size = sizeof(pcr0_unchanged_policy);
+		nvds_cmd.publicInfo.authPolicy.t.size =
+			sizeof(pcr0_unchanged_policy);
 	} else {
 		nvds_cmd.publicInfo.attributes = default_space_attributes;
 	}
@@ -360,7 +361,7 @@ uint32_t tlcl_define_space(uint32_t space_index, size_t space_size)
 		return TPM_E_NO_DEVICE;
 
 	/* Map TPM2 retrun codes into common vboot represenation. */
-	switch(response->hdr.tpm_code) {
+	switch (response->hdr.tpm_code) {
 	case TPM2_RC_SUCCESS:
 		return TPM_SUCCESS;
 	case TPM2_RC_NV_DEFINED:



More information about the coreboot-gerrit mailing list