diff mbox series

[2/4] libstb/tss/trustedTypes.C: Fix sparse annotations

Message ID 20200913225904.42537-2-stewart@flamingspork.com
State Not Applicable
Headers show
Series [1/4] core/opal.c: sparse cleanup integer as NULL | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d362ae4f4c521a7faffb1befe2fbba467f2c4d18)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Stewart Smith Sept. 13, 2020, 10:59 p.m. UTC
Lots of sparse warning fixes:
warning: incorrect type in assignment (different base types)
  expected unsigned short [usertype]
  got restricted leint16_t

Signed-off-by: Stewart Smith <stewart@flamingspork.com>
---
 libstb/tss/trustedTypes.C | 42 +++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

Comments

Vasant Hegde Nov. 27, 2020, 7:31 a.m. UTC | #1
On 9/14/20 4:29 AM, Stewart Smith wrote:
> Lots of sparse warning fixes:
> warning: incorrect type in assignment (different base types)
>    expected unsigned short [usertype]
>    got restricted leint16_t


Commit 9536adaa removed libstd/tss. Se we don't need this fix.

-Vasant

> 
> Signed-off-by: Stewart Smith <stewart@flamingspork.com>
> ---
>   libstb/tss/trustedTypes.C | 42 +++++++++++++++++++--------------------
>   1 file changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/libstb/tss/trustedTypes.C b/libstb/tss/trustedTypes.C
> index edc0269c..b73ca85c 100644
> --- a/libstb/tss/trustedTypes.C
> +++ b/libstb/tss/trustedTypes.C
> @@ -490,7 +490,7 @@ namespace TRUSTEDBOOT
> 
>       uint8_t* TPMT_HA_logMarshal(const TPMT_HA* val, uint8_t* i_logBuf)
>       {
> -        uint16_t* field16 = (uint16_t*)i_logBuf;
> +        __le16* field16 = (__le16*)i_logBuf;
>           *field16 = htole16(val->algorithmId);
>           i_logBuf += sizeof(uint16_t);
>           memcpy(i_logBuf, &(val->digest),
> @@ -503,14 +503,14 @@ namespace TRUSTEDBOOT
>                                           const uint8_t* i_tpmBuf, bool* o_err)
>       {
>           size_t size = 0;
> -        uint16_t* field16 = NULL;
> +        __le16* field16 = NULL;
> 
>           do {
>               *o_err = false;
> 
>               // algorithmId
>               size = sizeof(val->algorithmId);
> -            field16 = (uint16_t*)i_tpmBuf;
> +            field16 = (__le16*)i_tpmBuf;
>               val->algorithmId = le16toh(*field16);
>               // Ensure a valid count
>               if (val->algorithmId >= TPM_ALG_INVALID_ID)
> @@ -572,7 +572,7 @@ namespace TRUSTEDBOOT
>       uint8_t* TPML_DIGEST_VALUES_logMarshal(const TPML_DIGEST_VALUES* val,
>                                              uint8_t* i_logBuf)
>       {
> -        uint32_t* field32 = (uint32_t*)i_logBuf;
> +        __le32* field32 = (__le32*)i_logBuf;
>           if (HASH_COUNT < val->count)
>           {
>               i_logBuf = NULL;
> @@ -595,13 +595,13 @@ namespace TRUSTEDBOOT
>                                                      bool* o_err)
>       {
>           size_t size = 0;
> -        uint32_t* field32 = NULL;
> +        __le32* field32 = NULL;
>           do {
>               *o_err = false;
> 
>               // count
>               size = sizeof(val->count);
> -            field32 = (uint32_t*)(i_tpmBuf);
> +            field32 = (__le32*)(i_tpmBuf);
>               val->count = le32toh(*field32);
>               // Ensure a valid count
>               if (val->count > HASH_COUNT)
> @@ -651,7 +651,7 @@ namespace TRUSTEDBOOT
>                                                 bool* o_err)
>       {
>           size_t size = 0;
> -        uint32_t* field32;
> +        __le32* field32;
> 
>           *o_err = false;
>           do {
> @@ -665,7 +665,7 @@ namespace TRUSTEDBOOT
> 
>               // pcrIndex
>               size = sizeof(val->pcrIndex);
> -            field32 = (uint32_t*)(i_tpmBuf);
> +            field32 = (__le32*)(i_tpmBuf);
>               val->pcrIndex = le32toh(*field32);
>               // Ensure a valid pcr index
>               if (val->pcrIndex >= IMPLEMENTATION_PCR)
> @@ -681,7 +681,7 @@ namespace TRUSTEDBOOT
> 
>               // eventType
>               size = sizeof(val->eventType);
> -            field32 = (uint32_t*)(i_tpmBuf);
> +            field32 = (__le32*)(i_tpmBuf);
>               val->eventType = le32toh(*field32);
>               // Ensure a valid event type
>               if (val->eventType == 0 || val->eventType >= EV_INVALID)
> @@ -702,7 +702,7 @@ namespace TRUSTEDBOOT
> 
>               // eventSize
>               size = sizeof(val->eventSize);
> -            field32 = (uint32_t*)(i_tpmBuf);
> +            field32 = (__le32*)(i_tpmBuf);
>               val->eventSize = le32toh(*field32);
>               // Ensure a valid eventSize
>               if (val->eventSize >= MAX_TPM_LOG_MSG)
> @@ -727,18 +727,18 @@ namespace TRUSTEDBOOT
>       uint8_t* TCG_PCR_EVENT_logMarshal(const TCG_PCR_EVENT* val,
>                                         uint8_t* i_logBuf)
>       {
> -        uint32_t* field32 = (uint32_t*)(i_logBuf);
> +        __le32* field32 = (__le32*)(i_logBuf);
>           *field32 = htole32(val->pcrIndex);
>           i_logBuf += sizeof(uint32_t);
> 
> -        field32 = (uint32_t*)(i_logBuf);
> +        field32 = (__le32*)(i_logBuf);
>           *field32 = htole32(val->eventType);
>           i_logBuf += sizeof(uint32_t);
> 
>           memcpy(i_logBuf, val->digest, sizeof(val->digest));
>           i_logBuf += sizeof(val->digest);
> 
> -        field32 = (uint32_t*)(i_logBuf);
> +        field32 = (__le32*)(i_logBuf);
>           *field32 = htole32(val->eventSize);
>           i_logBuf += sizeof(uint32_t);
> 
> @@ -758,7 +758,7 @@ namespace TRUSTEDBOOT
>       uint8_t* TPM_EVENT_FIELD_logMarshal(const TPM_EVENT_FIELD* val,
>                                           uint8_t* i_logBuf)
>       {
> -        uint32_t* field32 = (uint32_t*)i_logBuf;
> +        __le32* field32 = (__le32*)i_logBuf;
>           if (MAX_TPM_LOG_MSG < val->eventSize)
>           {
>               i_logBuf = NULL;
> @@ -779,13 +779,13 @@ namespace TRUSTEDBOOT
>                                                   bool* o_err)
>       {
>           size_t size = 0;
> -        uint32_t* field32 = NULL;
> +        __le32* field32 = NULL;
>           do {
>               *o_err = false;
> 
>               // Event size
>               size = sizeof(val->eventSize);
> -            field32 = (uint32_t*)(i_tpmBuf);
> +            field32 = (__le32*)(i_tpmBuf);
>               val->eventSize = le32toh(*field32);
>               i_tpmBuf += size;
> 
> @@ -828,10 +828,10 @@ namespace TRUSTEDBOOT
>       uint8_t* TCG_PCR_EVENT2_logMarshal(const TCG_PCR_EVENT2* val,
>                                          uint8_t* i_logBuf)
>       {
> -        uint32_t* field32 = (uint32_t*)i_logBuf;
> +        __le32* field32 = (__le32*)i_logBuf;
>           *field32 = htole32(val->pcrIndex);
>           i_logBuf += sizeof(uint32_t);
> -        field32 = (uint32_t*)i_logBuf;
> +        field32 = (__le32*)i_logBuf;
>           *field32 = htole32(val->eventType);
>           i_logBuf += sizeof(uint32_t);
> 
> @@ -849,7 +849,7 @@ namespace TRUSTEDBOOT
>                                                  bool* o_err)
>       {
>           size_t size = 0;
> -        uint32_t* field32 = NULL;
> +        __le32* field32 = NULL;
> 
>           do {
>               *o_err = false;
> @@ -864,7 +864,7 @@ namespace TRUSTEDBOOT
> 
>               // pcrIndex
>               size = sizeof(val->pcrIndex);
> -            field32 = (uint32_t*)(i_tpmBuf);
> +            field32 = (__le32*)(i_tpmBuf);
>               val->pcrIndex = le32toh(*field32);
>               // Ensure a valid pcr index
>               if (val->pcrIndex > IMPLEMENTATION_PCR)
> @@ -880,7 +880,7 @@ namespace TRUSTEDBOOT
> 
>               // eventType
>               size = sizeof(val->eventType);
> -            field32 = (uint32_t*)(i_tpmBuf);
> +            field32 = (__le32*)(i_tpmBuf);
>               val->eventType = le32toh(*field32);
>               // Ensure a valid event type
>               if (val->eventType == 0 ||
>
diff mbox series

Patch

diff --git a/libstb/tss/trustedTypes.C b/libstb/tss/trustedTypes.C
index edc0269c..b73ca85c 100644
--- a/libstb/tss/trustedTypes.C
+++ b/libstb/tss/trustedTypes.C
@@ -490,7 +490,7 @@  namespace TRUSTEDBOOT
 
     uint8_t* TPMT_HA_logMarshal(const TPMT_HA* val, uint8_t* i_logBuf)
     {
-        uint16_t* field16 = (uint16_t*)i_logBuf;
+        __le16* field16 = (__le16*)i_logBuf;
         *field16 = htole16(val->algorithmId);
         i_logBuf += sizeof(uint16_t);
         memcpy(i_logBuf, &(val->digest),
@@ -503,14 +503,14 @@  namespace TRUSTEDBOOT
                                         const uint8_t* i_tpmBuf, bool* o_err)
     {
         size_t size = 0;
-        uint16_t* field16 = NULL;
+        __le16* field16 = NULL;
 
         do {
             *o_err = false;
 
             // algorithmId
             size = sizeof(val->algorithmId);
-            field16 = (uint16_t*)i_tpmBuf;
+            field16 = (__le16*)i_tpmBuf;
             val->algorithmId = le16toh(*field16);
             // Ensure a valid count
             if (val->algorithmId >= TPM_ALG_INVALID_ID)
@@ -572,7 +572,7 @@  namespace TRUSTEDBOOT
     uint8_t* TPML_DIGEST_VALUES_logMarshal(const TPML_DIGEST_VALUES* val,
                                            uint8_t* i_logBuf)
     {
-        uint32_t* field32 = (uint32_t*)i_logBuf;
+        __le32* field32 = (__le32*)i_logBuf;
         if (HASH_COUNT < val->count)
         {
             i_logBuf = NULL;
@@ -595,13 +595,13 @@  namespace TRUSTEDBOOT
                                                    bool* o_err)
     {
         size_t size = 0;
-        uint32_t* field32 = NULL;
+        __le32* field32 = NULL;
         do {
             *o_err = false;
 
             // count
             size = sizeof(val->count);
-            field32 = (uint32_t*)(i_tpmBuf);
+            field32 = (__le32*)(i_tpmBuf);
             val->count = le32toh(*field32);
             // Ensure a valid count
             if (val->count > HASH_COUNT)
@@ -651,7 +651,7 @@  namespace TRUSTEDBOOT
                                               bool* o_err)
     {
         size_t size = 0;
-        uint32_t* field32;
+        __le32* field32;
 
         *o_err = false;
         do {
@@ -665,7 +665,7 @@  namespace TRUSTEDBOOT
 
             // pcrIndex
             size = sizeof(val->pcrIndex);
-            field32 = (uint32_t*)(i_tpmBuf);
+            field32 = (__le32*)(i_tpmBuf);
             val->pcrIndex = le32toh(*field32);
             // Ensure a valid pcr index
             if (val->pcrIndex >= IMPLEMENTATION_PCR)
@@ -681,7 +681,7 @@  namespace TRUSTEDBOOT
 
             // eventType
             size = sizeof(val->eventType);
-            field32 = (uint32_t*)(i_tpmBuf);
+            field32 = (__le32*)(i_tpmBuf);
             val->eventType = le32toh(*field32);
             // Ensure a valid event type
             if (val->eventType == 0 || val->eventType >= EV_INVALID)
@@ -702,7 +702,7 @@  namespace TRUSTEDBOOT
 
             // eventSize
             size = sizeof(val->eventSize);
-            field32 = (uint32_t*)(i_tpmBuf);
+            field32 = (__le32*)(i_tpmBuf);
             val->eventSize = le32toh(*field32);
             // Ensure a valid eventSize
             if (val->eventSize >= MAX_TPM_LOG_MSG)
@@ -727,18 +727,18 @@  namespace TRUSTEDBOOT
     uint8_t* TCG_PCR_EVENT_logMarshal(const TCG_PCR_EVENT* val,
                                       uint8_t* i_logBuf)
     {
-        uint32_t* field32 = (uint32_t*)(i_logBuf);
+        __le32* field32 = (__le32*)(i_logBuf);
         *field32 = htole32(val->pcrIndex);
         i_logBuf += sizeof(uint32_t);
 
-        field32 = (uint32_t*)(i_logBuf);
+        field32 = (__le32*)(i_logBuf);
         *field32 = htole32(val->eventType);
         i_logBuf += sizeof(uint32_t);
 
         memcpy(i_logBuf, val->digest, sizeof(val->digest));
         i_logBuf += sizeof(val->digest);
 
-        field32 = (uint32_t*)(i_logBuf);
+        field32 = (__le32*)(i_logBuf);
         *field32 = htole32(val->eventSize);
         i_logBuf += sizeof(uint32_t);
 
@@ -758,7 +758,7 @@  namespace TRUSTEDBOOT
     uint8_t* TPM_EVENT_FIELD_logMarshal(const TPM_EVENT_FIELD* val,
                                         uint8_t* i_logBuf)
     {
-        uint32_t* field32 = (uint32_t*)i_logBuf;
+        __le32* field32 = (__le32*)i_logBuf;
         if (MAX_TPM_LOG_MSG < val->eventSize)
         {
             i_logBuf = NULL;
@@ -779,13 +779,13 @@  namespace TRUSTEDBOOT
                                                 bool* o_err)
     {
         size_t size = 0;
-        uint32_t* field32 = NULL;
+        __le32* field32 = NULL;
         do {
             *o_err = false;
 
             // Event size
             size = sizeof(val->eventSize);
-            field32 = (uint32_t*)(i_tpmBuf);
+            field32 = (__le32*)(i_tpmBuf);
             val->eventSize = le32toh(*field32);
             i_tpmBuf += size;
 
@@ -828,10 +828,10 @@  namespace TRUSTEDBOOT
     uint8_t* TCG_PCR_EVENT2_logMarshal(const TCG_PCR_EVENT2* val,
                                        uint8_t* i_logBuf)
     {
-        uint32_t* field32 = (uint32_t*)i_logBuf;
+        __le32* field32 = (__le32*)i_logBuf;
         *field32 = htole32(val->pcrIndex);
         i_logBuf += sizeof(uint32_t);
-        field32 = (uint32_t*)i_logBuf;
+        field32 = (__le32*)i_logBuf;
         *field32 = htole32(val->eventType);
         i_logBuf += sizeof(uint32_t);
 
@@ -849,7 +849,7 @@  namespace TRUSTEDBOOT
                                                bool* o_err)
     {
         size_t size = 0;
-        uint32_t* field32 = NULL;
+        __le32* field32 = NULL;
 
         do {
             *o_err = false;
@@ -864,7 +864,7 @@  namespace TRUSTEDBOOT
 
             // pcrIndex
             size = sizeof(val->pcrIndex);
-            field32 = (uint32_t*)(i_tpmBuf);
+            field32 = (__le32*)(i_tpmBuf);
             val->pcrIndex = le32toh(*field32);
             // Ensure a valid pcr index
             if (val->pcrIndex > IMPLEMENTATION_PCR)
@@ -880,7 +880,7 @@  namespace TRUSTEDBOOT
 
             // eventType
             size = sizeof(val->eventType);
-            field32 = (uint32_t*)(i_tpmBuf);
+            field32 = (__le32*)(i_tpmBuf);
             val->eventType = le32toh(*field32);
             // Ensure a valid event type
             if (val->eventType == 0 ||