]> git.proxmox.com Git - libtpms.git/commitdiff
tpm2: Address two more complaints by gcc 4.2.1 on i386 OpenBSD
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Wed, 26 Sep 2018 21:09:55 +0000 (17:09 -0400)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Wed, 26 Sep 2018 21:21:48 +0000 (17:21 -0400)
gcc 4.2.1 on i386 OpenBSD complains about two variables not having the
proper data type for %zu. This patch just casts the variables to size_t.

The comparison of a casted int against '< 0' also was a reason for
complaint since the evaluation of the variable would always be false
due to limited datatype. This patch also addresses this issue.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
src/tpm2/NVMarshal.c

index abb26c3e3a46070bd5e349cb11c0aad38bfbe17d..1bc1e20d9365958548af479eb282e28601b563c3 100644 (file)
@@ -1455,7 +1455,7 @@ bn_prime_t_Unmarshal(bn_prime_t *data, BYTE **buffer, INT32 *size)
         if (data->size > data->allocated) {
             TPMLIB_LogTPM2Error("bn_prime_t: Require size larger %zu than "
                                 "allocated %zu\n",
-                                data->size, data->allocated);
+                                (size_t)data->size, (size_t)data->allocated);
             rc = TPM_RC_SIZE;
         }
     }
@@ -4003,12 +4003,12 @@ INDEX_ORDERLY_RAM_Marshal(void *array, size_t array_size,
             break;
         }
         /* write data size before array */
-        datasize = nrh->size - sizeof(NV_RAM_HEADER);
-        if ((int)datasize < 0) {
+        if (nrh->size < sizeof(NV_RAM_HEADER)) {
             TPMLIB_LogTPM2Error("NV_ORDERLY_RAM: datasize corrupted: %d\n",
                                 (int)datasize);
             break;
         }
+        datasize = nrh->size - sizeof(NV_RAM_HEADER);
         written += UINT16_Marshal(&datasize, buffer, size);
         if (datasize > 0) {
             /* append the data */