]> git.proxmox.com Git - swtpm.git/commitdiff
swtpm: Fix compilation error on 32bit machines
authorStefan Berger <stefanb@linux.ibm.com>
Fri, 5 Nov 2021 19:02:05 +0000 (15:02 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Fri, 5 Nov 2021 20:58:54 +0000 (16:58 -0400)
Fix the following compilation error occurring on 32bit machines:

swtpm_nvstore_linear_file.c: In function 'SWTPM_NVRAM_LinearFile_Mmap':
swtpm_nvstore_linear_file.c:58:20: error: comparison of integer expressions of different signedness: '__off_t' {aka 'long int'} and 'unsigned int' [-Werror=sign-compare]
   58 |     if (st.st_size >= (uint32_t)sizeof(struct nvram_linear_hdr)) {
      |                    ^~

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
src/swtpm/swtpm_nvstore_linear_file.c

index d5e81593769b099bfee6b5e848599c165361d0c3..24dc7060cbbccad39e79d9a7c52e1ef3894a9efd 100644 (file)
@@ -55,7 +55,7 @@ SWTPM_NVRAM_LinearFile_Mmap(void)
         goto fail;
     }
 
-    if (st.st_size >= (uint32_t)sizeof(struct nvram_linear_hdr)) {
+    if (st.st_size >= (off_t)sizeof(struct nvram_linear_hdr)) {
         /* valid regular file-ish */
         mmap_state.size = st.st_size;
         mmap_state.can_truncate = true;