Merge branch 'master' into DecodeTidy
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index a600831..25f6cb9 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -33,24 +33,30 @@
 
 #include "qcbor/qcbor_decode.h"
 #include "qcbor/qcbor_spiffy_decode.h"
-#include "ieee754.h" // Does not use math.h
+#include "ieee754.h" /* Does not use math.h */
 
 #ifndef QCBOR_DISABLE_FLOAT_HW_USE
-#include <math.h> // For isnan(), llround(), llroudf(), round(), roundf(),
-                  // pow(), exp2()
-#include <fenv.h> // feclearexcept(), fetestexcept()
+
+#include <math.h> /* For isnan(), llround(), llroudf(), round(), roundf(),
+                   * pow(), exp2()
+                   */
+#include <fenv.h> /* feclearexcept(), fetestexcept() */
+
 #endif /* QCBOR_DISABLE_FLOAT_HW_USE */
 
 
+
 /*
- This casts away the const-ness of a pointer, usually so it can be
- freed or realloced.
+ * This casts away the const-ness of a pointer, usually so it can be
+ * freed or realloced.
  */
 #define UNCONST_POINTER(ptr)    ((void *)(ptr))
 
 #define SIZEOF_C_ARRAY(array,type) (sizeof(array)/sizeof(type))
 
 
+
+
 static inline bool
 QCBORItem_IsMapOrArray(const QCBORItem *pMe)
 {
@@ -97,8 +103,8 @@
   ===========================================================================*/
 
 /*
- See comments about and typedef of QCBORDecodeNesting in qcbor_private.h,
- the data structure all these functions work on.
+ * See comments about and typedef of QCBORDecodeNesting in qcbor_private.h,
+ * the data structure all these functions work on.
  */
 
 
@@ -106,9 +112,8 @@
 DecodeNesting_GetCurrentLevel(const QCBORDecodeNesting *pNesting)
 {
    const ptrdiff_t nLevel = pNesting->pCurrent - &(pNesting->pLevels[0]);
-   /*
-    Limit in DecodeNesting_Descend against more than
-    QCBOR_MAX_ARRAY_NESTING gaurantees cast is safe
+   /* Limit in DecodeNesting_Descend against more than
+    * QCBOR_MAX_ARRAY_NESTING gaurantees cast is safe
     */
    return (uint8_t)nLevel;
 }
@@ -118,9 +123,8 @@
 DecodeNesting_GetBoundedModeLevel(const QCBORDecodeNesting *pNesting)
 {
    const ptrdiff_t nLevel = pNesting->pCurrentBounded - &(pNesting->pLevels[0]);
-   /*
-    Limit in DecodeNesting_Descend against more than
-    QCBOR_MAX_ARRAY_NESTING gaurantees cast is safe
+   /* Limit in DecodeNesting_Descend against more than
+    * QCBOR_MAX_ARRAY_NESTING gaurantees cast is safe
     */
    return (uint8_t)nLevel;
 }
@@ -159,18 +163,19 @@
 DecodeNesting_IsCurrentDefiniteLength(const QCBORDecodeNesting *pNesting)
 {
    if(pNesting->pCurrent->uLevelType == QCBOR_TYPE_BYTE_STRING) {
-      // Not a map or array
+      /* Not a map or array */
       return false;
    }
 
 #ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
    if(pNesting->pCurrent->u.ma.uCountTotal == QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH) {
-      // Is indefinite
+      /* Is indefinite */
       return false;
    }
+
 #endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
 
-   // All checks passed; is a definte length map or array
+   /* All checks passed; is a definte length map or array */
    return true;
 }
 
@@ -178,7 +183,7 @@
 DecodeNesting_IsCurrentBstrWrapped(const QCBORDecodeNesting *pNesting)
 {
    if(pNesting->pCurrent->uLevelType == QCBOR_TYPE_BYTE_STRING) {
-      // is a byte string
+      /* is a byte string */
       return true;
    }
    return false;
@@ -199,11 +204,11 @@
 
 static inline void DecodeNesting_SetMapOrArrayBoundedMode(QCBORDecodeNesting *pNesting, bool bIsEmpty, size_t uStart)
 {
-   // Should be only called on maps and arrays
+   /* Should be only called on maps and arrays */
    /*
-    DecodeNesting_EnterBoundedMode() checks to be sure uStart is not
-    larger than DecodeNesting_EnterBoundedMode which keeps it less than
-    uin32_t so the cast is safe.
+    * DecodeNesting_EnterBoundedMode() checks to be sure uStart is not
+    * larger than DecodeNesting_EnterBoundedMode which keeps it less than
+    * uin32_t so the cast is safe.
     */
    pNesting->pCurrent->u.ma.uStartOffset = (uint32_t)uStart;
 
@@ -223,24 +228,24 @@
 DecodeNesting_IsAtEndOfBoundedLevel(const QCBORDecodeNesting *pNesting)
 {
    if(pNesting->pCurrentBounded == NULL) {
-      // No bounded map or array set up
+      /* No bounded map or array set up */
       return false;
    }
    if(pNesting->pCurrent->uLevelType == QCBOR_TYPE_BYTE_STRING) {
-      // Not a map or array; end of those is by byte count
+      /* Not a map or array; end of those is by byte count */
       return false;
    }
    if(!DecodeNesting_IsCurrentBounded(pNesting)) {
-      // In a traveral at a level deeper than the bounded level
+      /* In a traveral at a level deeper than the bounded level */
       return false;
    }
-   // Works for both definite and indefinite length maps/arrays
+   /* Works for both definite and indefinite length maps/arrays */
    if(pNesting->pCurrentBounded->u.ma.uCountCursor != 0 &&
       pNesting->pCurrentBounded->u.ma.uCountCursor != QCBOR_COUNT_INDICATES_ZERO_LENGTH) {
-      // Count is not zero, still unconsumed item
+      /* Count is not zero, still unconsumed item */
       return false;
    }
-   // All checks passed, got to the end of an array or map
+   /* All checks passed, got to the end of an array or map*/
    return true;
 }
 
@@ -248,7 +253,7 @@
 static inline bool
 DecodeNesting_IsEndOfDefiniteLengthMapOrArray(const QCBORDecodeNesting *pNesting)
 {
-   // Must only be called on map / array
+   /* Must only be called on map / array */
    if(pNesting->pCurrent->u.ma.uCountCursor == 0) {
       return true;
    } else {
@@ -286,7 +291,7 @@
 static inline void
 DecodeNesting_DecrementDefiniteLengthMapOrArrayCount(QCBORDecodeNesting *pNesting)
 {
-   // Only call on a defnite length array / map
+   /* Only call on a defnite length array / map */
    pNesting->pCurrent->u.ma.uCountCursor--;
 }
 
@@ -294,7 +299,7 @@
 static inline void
 DecodeNesting_ReverseDecrement(QCBORDecodeNesting *pNesting)
 {
-   // Only call on a defnite length array / map
+   /* Only call on a defnite length array / map */
    pNesting->pCurrent->u.ma.uCountCursor++;
 }
 
@@ -309,12 +314,12 @@
 static QCBORError
 DecodeNesting_Descend(QCBORDecodeNesting *pNesting, uint8_t uType)
 {
-   // Error out if nesting is too deep
+   /* Error out if nesting is too deep */
    if(pNesting->pCurrent >= &(pNesting->pLevels[QCBOR_MAX_ARRAY_NESTING])) {
       return QCBOR_ERR_ARRAY_DECODE_NESTING_TOO_DEEP;
    }
 
-   // The actual descend
+   /* The actual descend */
    pNesting->pCurrent++;
 
    pNesting->pCurrent->uLevelType = uType;
@@ -324,18 +329,20 @@
 
 
 static inline QCBORError
-DecodeNesting_EnterBoundedMapOrArray(QCBORDecodeNesting *pNesting, bool bIsEmpty, size_t uOffset)
+DecodeNesting_EnterBoundedMapOrArray(QCBORDecodeNesting *pNesting,
+                                     bool                bIsEmpty,
+                                     size_t              uOffset)
 {
    /*
-    Should only be called on map/array.
-
-    Have descended into this before this is called. The job here is
-    just to mark it in bounded mode.
-
-    Check against QCBOR_MAX_DECODE_INPUT_SIZE make sure that
-    uOffset doesn't collide with QCBOR_NON_BOUNDED_OFFSET
-
-    Cast of uOffset to uint32_t for cases where SIZE_MAX < UINT32_MAX.
+    * Should only be called on map/array.
+    *
+    * Have descended into this before this is called. The job here is
+    * just to mark it in bounded mode.
+    *
+    * Check against QCBOR_MAX_DECODE_INPUT_SIZE make sure that
+    * uOffset doesn't collide with QCBOR_NON_BOUNDED_OFFSET.
+    *
+    * Cast of uOffset to uint32_t for cases where SIZE_MAX < UINT32_MAX.
     */
    if((uint32_t)uOffset >= QCBOR_MAX_DECODE_INPUT_SIZE) {
       return QCBOR_ERR_INPUT_TOO_LARGE;
@@ -357,13 +364,14 @@
    QCBORError uError = QCBOR_SUCCESS;
 
    if(uCount == 0) {
-      // Nothing to do for empty definite lenth arrays. They are just are
-      // effectively the same as an item that is not a map or array
+      /* Nothing to do for empty definite lenth arrays. They are just are
+       * effectively the same as an item that is not a map or array.
+       */
       goto Done;
-      // Empty indefinite length maps and arrays are handled elsewhere
+      /* Empty indefinite length maps and arrays are handled elsewhere */
    }
 
-   // Error out if arrays is too long to handle
+   /* Error out if arrays is too long to handle */
    if(uCount != QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH &&
       uCount > QCBOR_MAX_ITEMS_IN_ARRAY) {
       uError = QCBOR_ERR_ARRAY_DECODE_TOO_LONG;
@@ -375,7 +383,7 @@
       goto Done;
    }
 
-   // Fill in the new map/array level. Check above makes casts OK.
+   /* Fill in the new map/array level. Check above makes casts OK. */
    pNesting->pCurrent->u.ma.uCountCursor  = (uint16_t)uCount;
    pNesting->pCurrent->u.ma.uCountTotal   = (uint16_t)uCount;
 
@@ -404,6 +412,7 @@
    }
 }
 
+
 static inline void
 DecodeNesting_SetCurrentToBoundedLevel(QCBORDecodeNesting *pNesting)
 {
@@ -423,11 +432,11 @@
       goto Done;
    }
 
-   // Fill in the new byte string level
+   /* Fill in the new byte string level */
    pNesting->pCurrent->u.bs.uPreviousEndOffset = uEndOffset;
    pNesting->pCurrent->u.bs.uEndOfBstr         = uEndOfBstr;
 
-   // Bstr wrapped levels are always bounded
+   /* Bstr wrapped levels are always bounded */
    pNesting->pCurrentBounded = pNesting->pCurrent;
 
 Done:
@@ -459,7 +468,8 @@
 
 
 static inline void
-DecodeNesting_PrepareForMapSearch(QCBORDecodeNesting *pNesting, QCBORDecodeNesting *pSave)
+DecodeNesting_PrepareForMapSearch(QCBORDecodeNesting *pNesting,
+                                  QCBORDecodeNesting *pSave)
 {
    *pSave = *pNesting;
    pNesting->pCurrent = pNesting->pCurrentBounded;
@@ -468,7 +478,8 @@
 
 
 static inline void
-DecodeNesting_RestoreFromMapSearch(QCBORDecodeNesting *pNesting, const QCBORDecodeNesting *pSave)
+DecodeNesting_RestoreFromMapSearch(QCBORDecodeNesting *pNesting,
+                                   const QCBORDecodeNesting *pSave)
 {
    *pNesting = *pSave;
 }
@@ -488,6 +499,8 @@
 }
 
 
+
+
 #ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS
 /*===========================================================================
    QCBORStringAllocate -- STRING ALLOCATOR INVOCATION
@@ -529,6 +542,8 @@
 #endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
 
 
+
+
 /*===========================================================================
  QCBORDecode -- The main implementation of CBOR decoding
 
@@ -536,16 +551,17 @@
  used here: QCBORDecodeContext
   ===========================================================================*/
 /*
- Public function, see header file
+ * Public function, see header file
  */
 void QCBORDecode_Init(QCBORDecodeContext *me,
-                      UsefulBufC EncodedCBOR,
-                      QCBORDecodeMode nDecodeMode)
+                      UsefulBufC          EncodedCBOR,
+                      QCBORDecodeMode     nDecodeMode)
 {
    memset(me, 0, sizeof(QCBORDecodeContext));
    UsefulInputBuf_Init(&(me->InBuf), EncodedCBOR);
-   // Don't bother with error check on decode mode. If a bad value is
-   // passed it will just act as if the default normal mode of 0 was set.
+   /* Don't bother with error check on decode mode. If a bad value is
+    * passed it will just act as if the default normal mode of 0 was set.
+    */
    me->uDecodeMode = (uint8_t)nDecodeMode;
    DecodeNesting_Init(&(me->nesting));
    for(int i = 0; i < QCBOR_NUM_MAPPED_TAGS; i++) {
@@ -557,12 +573,12 @@
 #ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS
 
 /*
- Public function, see header file
+ * Public function, see header file
  */
 void QCBORDecode_SetUpAllocator(QCBORDecodeContext *pMe,
                                 QCBORStringAllocate pfAllocateFunction,
-                                void *pAllocateContext,
-                                bool bAllStrings)
+                                void               *pAllocateContext,
+                                bool                bAllStrings)
 {
    pMe->StringAllocator.pfAllocator   = pfAllocateFunction;
    pMe->StringAllocator.pAllocateCxt  = pAllocateContext;
@@ -571,154 +587,166 @@
 #endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
 
 
+
+
 /*
- Public function, see header file
+ * Deprecated public function, see header file
  */
-void QCBORDecode_SetCallerConfiguredTagList(QCBORDecodeContext *pMe,
+void QCBORDecode_SetCallerConfiguredTagList(QCBORDecodeContext   *pMe,
                                             const QCBORTagListIn *pTagList)
 {
-   // This does nothing now. It is retained for backwards compatibility
+   /* This does nothing now. It is retained for backwards compatibility */
    (void)pMe;
    (void)pTagList;
 }
 
 
-/*
- This decodes the fundamental part of a CBOR data item, the type and
- number
-
- This is the counterpart to QCBOREncode_EncodeHead().
-
- This does the network->host byte order conversion. The conversion
- here also results in the conversion for floats in addition to that
- for lengths, tags and integer values.
-
- This returns:
-   pnMajorType -- the major type for the item
-
-   puArgument -- the "number" which is used a the value for integers,
-               tags and floats and length for strings and arrays
-
-   pnAdditionalInfo -- Pass this along to know what kind of float or
-                       if length is indefinite
-
- The int type is preferred to uint8_t for some variables as this
- avoids integer promotions, can reduce code size and makes
- static analyzers happier.
-
- @retval QCBOR_ERR_UNSUPPORTED
-
- @retval QCBOR_ERR_HIT_END
+/**
+ * @brief Decode the CBOR head, the type and argument.
+ *
+ * @param[in] pUInBuf            The input buffer to read from.
+ * @param[out] pnMajorType       The decoded major type.
+ * @param[out] puArgument        The decoded argument.
+ * @param[out] pnAdditionalInfo  The decoded Lower 5 bits of initial byte.
+ *
+ *  @retval QCBOR_ERR_UNSUPPORTED
+ *  @retval QCBOR_ERR_HIT_END
+ *
+ * This decodes the CBOR "head" that every CBOR data item has. See
+ * longer explaination of the head in documentation for
+ * QCBOREncode_EncodeHead().
+ *
+ * This does the network->host byte order conversion. The conversion
+ * here also results in the conversion for floats in addition to that
+ * for lengths, tags and integer values.
+ *
+ * The int type is preferred to uint8_t for some variables as this
+ * avoids integer promotions, can reduce code size and makes static
+ * analyzers happier.
  */
-static inline QCBORError DecodeTypeAndNumber(UsefulInputBuf *pUInBuf,
-                                              int *pnMajorType,
-                                              uint64_t *puArgument,
-                                              int *pnAdditionalInfo)
+static inline QCBORError
+DecodeHead(UsefulInputBuf *pUInBuf,
+           int            *pnMajorType,
+           uint64_t       *puArgument,
+           int            *pnAdditionalInfo)
 {
-   QCBORError nReturn;
+   QCBORError uReturn;
 
-   // Get the initial byte that every CBOR data item has
-   const int nInitialByte = (int)UsefulInputBuf_GetByte(pUInBuf);
-
-   // Break down the initial byte
+   /* Get the initial byte that every CBOR data item has and break it
+    * down. */
+   const int nInitialByte    = (int)UsefulInputBuf_GetByte(pUInBuf);
    const int nTmpMajorType   = nInitialByte >> 5;
    const int nAdditionalInfo = nInitialByte & 0x1f;
 
-   // Where the number or argument accumulates
+   /* Where the argument accumulates */
    uint64_t uArgument;
 
    if(nAdditionalInfo >= LEN_IS_ONE_BYTE && nAdditionalInfo <= LEN_IS_EIGHT_BYTES) {
-      // Need to get 1,2,4 or 8 additional argument bytes. Map
-      // LEN_IS_ONE_BYTE..LEN_IS_EIGHT_BYTES to actual length
+      /* Need to get 1,2,4 or 8 additional argument bytes. Map
+       * LEN_IS_ONE_BYTE..LEN_IS_EIGHT_BYTES to actual length.
+       */
       static const uint8_t aIterate[] = {1,2,4,8};
 
-      // Loop getting all the bytes in the argument
+      /* Loop getting all the bytes in the argument */
       uArgument = 0;
       for(int i = aIterate[nAdditionalInfo - LEN_IS_ONE_BYTE]; i; i--) {
-         // This shift and add gives the endian conversion
+         /* This shift and add gives the endian conversion. */
          uArgument = (uArgument << 8) + UsefulInputBuf_GetByte(pUInBuf);
       }
    } else if(nAdditionalInfo >= ADDINFO_RESERVED1 && nAdditionalInfo <= ADDINFO_RESERVED3) {
-      // The reserved and thus-far unused additional info values
-      nReturn = QCBOR_ERR_UNSUPPORTED;
+      /* The reserved and thus-far unused additional info values */
+      uReturn = QCBOR_ERR_UNSUPPORTED;
       goto Done;
    } else {
-      // Less than 24, additional info is argument or 31, an indefinite length
-      // No more bytes to get
+      /* Less than 24, additional info is argument or 31, an
+       * indefinite length.  No more bytes to get.
+       */
       uArgument = (uint64_t)nAdditionalInfo;
    }
 
    if(UsefulInputBuf_GetError(pUInBuf)) {
-      nReturn = QCBOR_ERR_HIT_END;
+      uReturn = QCBOR_ERR_HIT_END;
       goto Done;
    }
 
-   // All successful if we got here.
-   nReturn           = QCBOR_SUCCESS;
+   /* All successful if arrived here. */
+   uReturn           = QCBOR_SUCCESS;
    *pnMajorType      = nTmpMajorType;
    *puArgument       = uArgument;
    *pnAdditionalInfo = nAdditionalInfo;
 
 Done:
-   return nReturn;
+   return uReturn;
 }
 
 
-/*
- CBOR doesn't explicitly specify two's compliment for integers but all
- CPUs use it these days and the test vectors in the RFC are so. All
- integers in the CBOR structure are positive and the major type
- indicates positive or negative.  CBOR can express positive integers
- up to 2^x - 1 where x is the number of bits and negative integers
- down to 2^x.  Note that negative numbers can be one more away from
- zero than positive.  Stdint, as far as I can tell, uses two's
- compliment to represent negative integers.
-
- See http://www.unix.org/whitepapers/64bit.html for reasons int is
- used carefully here, and in particular why it isn't used in the interface.
- Also see
- https://stackoverflow.com/questions/17489857/why-is-int-typically-32-bit-on-64-bit-compilers
-
- Int is used for values that need less than 16-bits and would be subject
- to integer promotion and complaining by static analyzers.
-
- @retval QCBOR_ERR_INT_OVERFLOW
+/**
+ * @brief Decode integer types, major types 0 and 1.
+ *
+ * @param[in] nMajorType     The CBOR major type (0 or 1).
+ * @param[in] uArgument      The argument from the head.
+ * @param[out] pDecodedItem  The filled in decoded item.
+ *
+ * @retval QCBOR_ERR_INT_OVERFLOW
+ *
+ * Must only be called when major type is 0 or 1.
+ *
+ * CBOR doesn't explicitly specify two's compliment for integers but
+ * all CPUs use it these days and the test vectors in the RFC are
+ * so. All integers in the CBOR structure are positive and the major
+ * type indicates positive or negative.  CBOR can express positive
+ * integers up to 2^x - 1 where x is the number of bits and negative
+ * integers down to 2^x.  Note that negative numbers can be one more
+ * away from zero than positive.  Stdint, as far as I can tell, uses
+ * two's compliment to represent negative integers.
+ *
+ * See http://www.unix.org/whitepapers/64bit.html for reasons int is
+ * used carefully here, and in particular why it isn't used in the
+ * public interface.  Also see
+ * https://stackoverflow.com/questions/17489857/why-is-int-typically-32-bit-on-64-bit-compilers
+ *
+ * Int is used for values that need less than 16-bits and would be
+ * subject to integer promotion and result in complaining from static
+ * analyzers.
  */
 static inline QCBORError
-DecodeInteger(int nMajorType, uint64_t uNumber, QCBORItem *pDecodedItem)
+DecodeInteger(int nMajorType, uint64_t uArgument, QCBORItem *pDecodedItem)
 {
-   QCBORError nReturn = QCBOR_SUCCESS;
+   QCBORError uReturn = QCBOR_SUCCESS;
 
    if(nMajorType == CBOR_MAJOR_TYPE_POSITIVE_INT) {
-      if (uNumber <= INT64_MAX) {
-         pDecodedItem->val.int64 = (int64_t)uNumber;
+      if (uArgument <= INT64_MAX) {
+         pDecodedItem->val.int64 = (int64_t)uArgument;
          pDecodedItem->uDataType = QCBOR_TYPE_INT64;
 
       } else {
-         pDecodedItem->val.uint64 = uNumber;
+         pDecodedItem->val.uint64 = uArgument;
          pDecodedItem->uDataType  = QCBOR_TYPE_UINT64;
-
       }
+
    } else {
-      if(uNumber <= INT64_MAX) {
-         // CBOR's representation of negative numbers lines up with the
-         // two-compliment representation. A negative integer has one
-         // more in range than a positive integer. INT64_MIN is
-         // equal to (-INT64_MAX) - 1.
-         pDecodedItem->val.int64 = (-(int64_t)uNumber) - 1;
+      if(uArgument <= INT64_MAX) {
+         /* CBOR's representation of negative numbers lines up with
+          * the two-compliment representation. A negative integer has
+          * one more in range than a positive integer. INT64_MIN is
+          * equal to (-INT64_MAX) - 1.
+          */
+         pDecodedItem->val.int64 = (-(int64_t)uArgument) - 1;
          pDecodedItem->uDataType = QCBOR_TYPE_INT64;
 
       } else {
-         // C can't represent a negative integer in this range
-         // so it is an error.
-         nReturn = QCBOR_ERR_INT_OVERFLOW;
+         /* C can't represent a negative integer in this range so it
+          * is an error.
+          */
+         uReturn = QCBOR_ERR_INT_OVERFLOW;
       }
    }
 
-   return nReturn;
+   return uReturn;
 }
 
-// Make sure #define value line up as DecodeSimple counts on this.
+
+/* Make sure #define value line up as DecodeSimple counts on this. */
 #if QCBOR_TYPE_FALSE != CBOR_SIMPLEV_FALSE
 #error QCBOR_TYPE_FALSE macro value wrong
 #endif
@@ -747,102 +775,112 @@
 #error QCBOR_TYPE_FLOAT macro value wrong
 #endif
 
+
 /*
- Decode true, false, floats, break...
+* @brief Decode type 7 -- true, false, floating-point, break...
+*
+* @param[in] nAdditionalInfo   The lower five bits from the initial byte.
+* @param[in] uArgument         The argument from the head.
+* @param[out] pDecodedItem     The filled in decoded item.
+*
+* @retval QCBOR_ERR_HALF_PRECISION_DISABLED
+* @retval QCBOR_ERR_BAD_TYPE_7
+*/
 
- @retval QCBOR_ERR_HALF_PRECISION_DISABLED
-
- @retval QCBOR_ERR_BAD_TYPE_7
- */
 static inline QCBORError
-DecodeSimple(int nAdditionalInfo, uint64_t uNumber, QCBORItem *pDecodedItem)
+DecodeSimple(int nAdditionalInfo, uint64_t uArgument, QCBORItem *pDecodedItem)
 {
-   QCBORError nReturn = QCBOR_SUCCESS;
+   QCBORError uReturn = QCBOR_SUCCESS;
 
-   // uAdditionalInfo is 5 bits from the initial byte. Compile time checks
-   // above make sure uAdditionalInfo values line up with uDataType values.
-   // DecodeTypeAndNumber() never returns an AdditionalInfo > 0x1f so cast
-   // is safe
+   /* uAdditionalInfo is 5 bits from the initial byte. Compile time
+    * checks above make sure uAdditionalInfo values line up with
+    * uDataType values.  DecodeHead() never returns an AdditionalInfo
+    * > 0x1f so cast is safe.
+    */
    pDecodedItem->uDataType = (uint8_t)nAdditionalInfo;
 
    switch(nAdditionalInfo) {
-      // No check for ADDINFO_RESERVED1 - ADDINFO_RESERVED3 as they are
-      // caught before this is called.
+      /* No check for ADDINFO_RESERVED1 - ADDINFO_RESERVED3 as they
+       * are caught before this is called.
+       */
 
-      case HALF_PREC_FLOAT: // 25
+      case HALF_PREC_FLOAT: /* 25 */
 #ifndef QCBOR_DISABLE_PREFERRED_FLOAT
-         // Half-precision is returned as a double.
-         // The cast to uint16_t is safe because the encoded value
-         // was 16 bits. It was widened to 64 bits to be passed in here.
-         pDecodedItem->val.dfnum = IEEE754_HalfToDouble((uint16_t)uNumber);
+         /* Half-precision is returned as a double.  The cast to
+          * uint16_t is safe because the encoded value was 16 bits. It
+          * was widened to 64 bits to be passed in here.
+          */
+         pDecodedItem->val.dfnum = IEEE754_HalfToDouble((uint16_t)uArgument);
          pDecodedItem->uDataType = QCBOR_TYPE_DOUBLE;
 #else /* QCBOR_DISABLE_PREFERRED_FLOAT */
-         nReturn = QCBOR_ERR_HALF_PRECISION_DISABLED;
+         uReturn = QCBOR_ERR_HALF_PRECISION_DISABLED;
 #endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
          break;
-      case SINGLE_PREC_FLOAT: // 26
-         // Single precision is normally returned as a double
-         // since double is widely supported, there is no loss of
-         // precision, it makes it easy for the caller in
-         // most cases and it can be converted back to single
-         // with no loss of precision
-         //
-         // The cast to uint32_t is safe because the encoded value
-         // was 32 bits. It was widened to 64 bits to be passed in here.
+      case SINGLE_PREC_FLOAT: /* 26 */
+         /* Single precision is normally returned as a double since
+          * double is widely supported, there is no loss of precision,
+          * it makes it easy for the caller in most cases and it can
+          * be converted back to single with no loss of precision
+          *
+          * The cast to uint32_t is safe because the encoded value was
+          * 32 bits. It was widened to 64 bits to be passed in here.
+          */
          {
-            const float f = UsefulBufUtil_CopyUint32ToFloat((uint32_t)uNumber);
+            const float f = UsefulBufUtil_CopyUint32ToFloat((uint32_t)uArgument);
 #ifndef QCBOR_DISABLE_FLOAT_HW_USE
-            // In the normal case, use HW to convert float to double.
+            /* In the normal case, use HW to convert float to
+	          * double. */
             pDecodedItem->val.dfnum = (double)f;
             pDecodedItem->uDataType = QCBOR_TYPE_DOUBLE;
 #else /* QCBOR_DISABLE_FLOAT_HW_USE */
-            // Use of float HW is disabled, return as a float.
+            /* Use of float HW is disabled, return as a float. */
             pDecodedItem->val.fnum = f;
             pDecodedItem->uDataType = QCBOR_TYPE_FLOAT;
 
-            // IEEE754_FloatToDouble() could be used here to return
-            // as a double, but it adds object code and most likely
-            // anyone disabling FLOAT HW use doesn't care about
-            // floats and wants to save object code.
+            /* IEEE754_FloatToDouble() could be used here to return as
+             * a double, but it adds object code and most likely
+             * anyone disabling FLOAT HW use doesn't care about floats
+             * and wants to save object code.
+             */
 #endif /* QCBOR_DISABLE_FLOAT_HW_USE */
          }
          break;
 
-      case DOUBLE_PREC_FLOAT: // 27
-         pDecodedItem->val.dfnum = UsefulBufUtil_CopyUint64ToDouble(uNumber);
+      case DOUBLE_PREC_FLOAT: /* 27 */
+         pDecodedItem->val.dfnum = UsefulBufUtil_CopyUint64ToDouble(uArgument);
          pDecodedItem->uDataType = QCBOR_TYPE_DOUBLE;
          break;
 
-      case CBOR_SIMPLEV_FALSE: // 20
-      case CBOR_SIMPLEV_TRUE:  // 21
-      case CBOR_SIMPLEV_NULL:  // 22
-      case CBOR_SIMPLEV_UNDEF: // 23
-      case CBOR_SIMPLE_BREAK:  // 31
-         break; // nothing to do
+      case CBOR_SIMPLEV_FALSE: /* 20 */
+      case CBOR_SIMPLEV_TRUE:  /* 21 */
+      case CBOR_SIMPLEV_NULL:  /* 22 */
+      case CBOR_SIMPLEV_UNDEF: /* 23 */
+      case CBOR_SIMPLE_BREAK:  /* 31 */
+         break; /* nothing to do */
 
-      case CBOR_SIMPLEV_ONEBYTE: // 24
-         if(uNumber <= CBOR_SIMPLE_BREAK) {
-            // This takes out f8 00 ... f8 1f which should be encoded as e0 … f7
-            nReturn = QCBOR_ERR_BAD_TYPE_7;
+      case CBOR_SIMPLEV_ONEBYTE: /* 24 */
+         if(uArgument <= CBOR_SIMPLE_BREAK) {
+            /* This takes out f8 00 ... f8 1f which should be encoded
+             * as e0 … f7
+             */
+            uReturn = QCBOR_ERR_BAD_TYPE_7;
             goto Done;
          }
          /* FALLTHROUGH */
-         // fall through intentionally
 
-      default: // 0-19
+      default: /* 0-19 */
          pDecodedItem->uDataType   = QCBOR_TYPE_UKNOWN_SIMPLE;
-         /*
-          DecodeTypeAndNumber will make uNumber equal to
-          uAdditionalInfo when uAdditionalInfo is < 24 This cast is
-          safe because the 2, 4 and 8 byte lengths of uNumber are in
-          the double/float cases above
+         /* DecodeHead() will make uArgument equal to
+          * nAdditionalInfo when nAdditionalInfo is < 24. This cast is
+          * safe because the 2, 4 and 8 byte lengths of uNumber are in
+          * the double/float cases above
           */
-         pDecodedItem->val.uSimple = (uint8_t)uNumber;
+         pDecodedItem->val.uSimple = (uint8_t)uArgument;
          break;
    }
 
 Done:
-   return nReturn;
+   return uReturn;
 }
 
 
@@ -855,10 +893,11 @@
 
  @retval QCBOR_ERR_STRING_TOO_LONG
  */
-static inline QCBORError DecodeBytes(const QCBORInternalAllocator *pAllocator,
-                                     uint64_t uStrLen,
-                                     UsefulInputBuf *pUInBuf,
-                                     QCBORItem *pDecodedItem)
+static inline QCBORError
+DecodeBytes(const QCBORInternalAllocator *pAllocator,
+            uint64_t                      uStrLen,
+            UsefulInputBuf               *pUInBuf,
+            QCBORItem                    *pDecodedItem)
 {
    QCBORError nReturn = QCBOR_SUCCESS;
 
@@ -965,12 +1004,12 @@
     floats and doubles
    */
    int      nMajorType = 0;
-   uint64_t uNumber = 0;
+   uint64_t uArgument = 0;
    int      nAdditionalInfo = 0;
 
    memset(pDecodedItem, 0, sizeof(QCBORItem));
 
-   nReturn = DecodeTypeAndNumber(pUInBuf, &nMajorType, &uNumber, &nAdditionalInfo);
+   nReturn = DecodeHead(pUInBuf, &nMajorType, &uArgument, &nAdditionalInfo);
 
    // Error out here if we got into trouble on the type and number.  The
    // code after this will not work if the type and number is not good.
@@ -986,7 +1025,7 @@
          if(nAdditionalInfo == LEN_IS_INDEFINITE) {
             nReturn = QCBOR_ERR_BAD_INT;
          } else {
-            nReturn = DecodeInteger(nMajorType, uNumber, pDecodedItem);
+            nReturn = DecodeInteger(nMajorType, uArgument, pDecodedItem);
          }
          break;
 
@@ -996,14 +1035,14 @@
          if(nAdditionalInfo == LEN_IS_INDEFINITE) {
             pDecodedItem->val.string = (UsefulBufC){NULL, QCBOR_STRING_LENGTH_INDEFINITE};
          } else {
-            nReturn = DecodeBytes(pAllocator, uNumber, pUInBuf, pDecodedItem);
+            nReturn = DecodeBytes(pAllocator, uArgument, pUInBuf, pDecodedItem);
          }
          break;
 
       case CBOR_MAJOR_TYPE_ARRAY: // Major type 4
       case CBOR_MAJOR_TYPE_MAP:   // Major type 5
          // Record the number of items in the array or map
-         if(uNumber > QCBOR_MAX_ITEMS_IN_ARRAY) {
+         if(uArgument > QCBOR_MAX_ITEMS_IN_ARRAY) {
             nReturn = QCBOR_ERR_ARRAY_DECODE_TOO_LONG;
             goto Done;
          }
@@ -1016,7 +1055,7 @@
 #endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
          } else {
             // type conversion OK because of check above
-            pDecodedItem->val.uCount = (uint16_t)uNumber;
+            pDecodedItem->val.uCount = (uint16_t)uArgument;
          }
          // C preproc #if above makes sure constants for major types align
          // DecodeTypeAndNumber never returns a major type > 7 so cast is safe
@@ -1027,14 +1066,14 @@
          if(nAdditionalInfo == LEN_IS_INDEFINITE) {
             nReturn = QCBOR_ERR_BAD_INT;
          } else {
-            pDecodedItem->val.uTagV = uNumber;
+            pDecodedItem->val.uTagV = uArgument;
             pDecodedItem->uDataType = QCBOR_TYPE_TAG;
          }
          break;
 
       case CBOR_MAJOR_TYPE_SIMPLE:
          // Major type 7, float, double, true, false, null...
-         nReturn = DecodeSimple(nAdditionalInfo, uNumber, pDecodedItem);
+         nReturn = DecodeSimple(nAdditionalInfo, uArgument, pDecodedItem);
          break;
 
       default: