[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [libosinfo 1/5] Fix gint64 format string in osinfo_entity_set_param_int64



osinfo_entity_set_param_int64 printed gint64 values using
G_GUINT64_FORMAT which is unwanted when the value is
negative. This bug caused breakage after the changes in
84969ff9 and 4e86e2bf when trying to read the install-reboot value.

Until these commits, we stored the textual representation
of (guint64)-1 (GUINT_MAX) in the entity store, and when trying to convert
it, g_ascii_strtod was returning -GINT64_MAX, and
osinfo_entity_get_param_value_int64_with_default was returning the
default value as this value is negative.

After these commits, g_ascii_strtoll returns GINT64_MAX-1 when trying
to parse the overlong string stored in the database, and the default
value is not returned as the data was found in the database.

Just using the right format (G_GINT64_FORMAT) to convert a gint64 to a
string fixes this bug.
---
 osinfo/osinfo_entity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
index 0e4b2a4..e9dabfe 100644
--- a/osinfo/osinfo_entity.c
+++ b/osinfo/osinfo_entity.c
@@ -206,7 +206,7 @@ void osinfo_entity_set_param_int64(OsinfoEntity *entity, const gchar *key, gint6
 {
     gchar *str;
 
-    str = g_strdup_printf("%"G_GUINT64_FORMAT, value);
+    str = g_strdup_printf("%"G_GINT64_FORMAT, value);
     osinfo_entity_set_param(entity, key, str);
     g_free(str);
 }
-- 
1.8.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]