Skip to contentSkip to conversation

smbios: fixed compiler warning on clang > 3.4

PATCH In review SeokYeon Hwang 2 participants 3 messages Oct 31, 2014 – Nov 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smbios: fixed compiler warning on clang > 3.4

Explicit casting to 'ram_addr_t' in order to avoid "-Wconstant-conversion" on clang 3.4 or later.

---
 hw/i386/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/smbios.c +1 -1
index e3fa1b2..ace9c44 100644
@@ -836,7 +836,7 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len,
         smbios_build_type_16_table(dimm_cnt);
 
         for (i = 0; i < dimm_cnt; i++) {
-            smbios_build_type_17_table(i, GET_DIMM_SZ);
+            smbios_build_type_17_table(i, (ram_addr_t)GET_DIMM_SZ);
         }
 
         for (i = 0, instance = 0; i < e820_get_num_entries(); i++) {
Signature · 1 line
2.1.0
#1 lore raw
Quoted 13 lines · SeokYeon Hwang

Explicit casting to 'ram_addr_t' in order to avoid "-Wconstant-conversion" on clang 3.4 or later.

---
 hw/i386/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/smbios.c +0 -0
index e3fa1b2..ace9c44 100644

hw/i386/smbios.c void smbios_get_tables(uint8_t **tables, size_t *tables_len, · line 842

Quoted 8 lines
hw/i386/smbios.c +1 -1
@@ -836,7 +836,7 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len,
         smbios_build_type_16_table(dimm_cnt);
 
         for (i = 0; i < dimm_cnt; i++) {
-            smbios_build_type_17_table(i, GET_DIMM_SZ);
+            smbios_build_type_17_table(i, (ram_addr_t)GET_DIMM_SZ);
         }
 
         for (i = 0, instance = 0; i < e820_get_num_entries(); i++) {

I'm not sure what the problem is. Can you instead do something like:

         for (i = 0; i < dimm_cnt; i++) {
-            smbios_build_type_17_table(i, GET_DIMM_SZ);
+            uint64_t sz = (i < dimm_cnt - 1) ? MAX_DIMM_SZ : ram_size % MAX_DIMM_SZ;
+            smbios_build_type_17_table(i, sz);
         }

and change smbios_build_type_17_table to take simply a uint64_t? Using ram_addr_t is probably wrong.

Paolo

#2 lore raw
Quoted 39 lines

-----Original Message-----
From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini
Sent: Tuesday, November 04, 2014 1:16 AM
To: SeokYeon Hwang; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] smbios: fixed compiler warning on clang > 3.4

Quoted 1 line · SeokYeon Hwang

Explicit casting to 'ram_addr_t' in order to avoid "-Wconstant-

conversion" on clang 3.4 or later.

hw/i386/smbios.c void smbios_get_tables(uint8_t **tables, size_t

Quoted 11 lines
---
 hw/i386/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/smbios.c index renamed from hw/i386/smbios.c +0 -0

e3fa1b2..ace9c44 100644

hw/i386/smbios.c +0 -0
@@ -836,7 +836,7 @@ void smbios_get_tables(uint8_t **tables, size_t

*tables_len,

hw/i386/smbios.c void smbios_get_tables(uint8_t **tables, size_t *tables_len, · line 842

Quoted 9 lines
hw/i386/smbios.c +1 -1
         smbios_build_type_16_table(dimm_cnt);
 
         for (i = 0; i < dimm_cnt; i++) {
-            smbios_build_type_17_table(i, GET_DIMM_SZ);
+            smbios_build_type_17_table(i, (ram_addr_t)GET_DIMM_SZ);
         }
 
         for (i = 0, instance = 0; i < e820_get_num_entries(); i++) {

I'm not sure what the problem is. Can you instead do something like:

         for (i = 0; i < dimm_cnt; i++) {
(quoted diff) +1 -1
-            smbios_build_type_17_table(i, GET_DIMM_SZ);
+            uint64_t sz = (i < dimm_cnt - 1) ? MAX_DIMM_SZ : ram_size %

MAX_DIMM_SZ;

Quoted 7 lines
+            smbios_build_type_17_table(i, sz);
         }

and change smbios_build_type_17_table to take simply a uint64_t? Using ram_addr_t is probably wrong.

Paolo

You are right. "smbios_build_type_17_table()" should take uint64_t. I will post patch v2.

Thanks.