[virt-tools-list] [PATCH 2/2] Fix "__warn_memset_zero_len"

Fabiano Fidêncio fabiano at fidencio.org
Fri Mar 23 12:05:57 UTC 2012


---
 tools/osinfo-query.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/osinfo-query.c b/tools/osinfo-query.c
index 8c96b62..69b789a 100644
--- a/tools/osinfo-query.c
+++ b/tools/osinfo-query.c
@@ -251,9 +251,11 @@ static gboolean print_entity_text(OsinfoEntity *entity,
             pad = labels[i].width - (val ? strlen(val) : 0);
 
         padstr = g_new0(gchar, pad+1);
-        memset(padstr, ' ', pad);
         padstr[pad] = '\0';
 
+        if (pad)
+            memset(padstr, ' ', pad);
+
         g_print("%s%s",
                 val ? val : "", padstr);
         g_free(padstr);
@@ -295,9 +297,11 @@ static gboolean print_results_text(OsinfoList *list,
             pad = labels[i].width - strlen(labels[i].label);
 
         padstr = g_new0(gchar, pad+1);
-        memset(padstr, ' ', pad);
         padstr[pad] = '\0';
 
+        if (pad)
+            memset(padstr, ' ', pad);
+
         g_print("%s%s",
                 labels[i].label, padstr);
         g_free(padstr);
-- 
1.7.9.3




More information about the virt-tools-list mailing list