[Xfce4-commits] <xfce4-taskmanager:master> [linux] Fix 64-bit issue with scanf

Mike Massonnet noreply at xfce.org
Tue Jun 8 10:32:01 CEST 2010


Updating branch refs/heads/master
         to bdeff4e269e8ae1f734486d8ae10d6489c5116b5 (commit)
       from 1a389837df96b543abbd8c7d046ba9ef19df8323 (commit)

commit bdeff4e269e8ae1f734486d8ae10d6489c5116b5
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Tue Jun 8 06:18:44 2010 -0400

    [linux] Fix 64-bit issue with scanf
    
    The fix is very trivial, all it takes is initializing values passed to
    scanf to zero. In fact format conversions inside scanf/printf may fail
    otherwise.

 src/task-manager-linux.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/task-manager-linux.c b/src/task-manager-linux.c
index 0c8204a..030258d 100644
--- a/src/task-manager-linux.c
+++ b/src/task-manager-linux.c
@@ -33,6 +33,13 @@ get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64 *memory_c
 	if ((file = fopen (filename, "r")) == NULL)
 		return FALSE;
 
+	*memory_total = 0;
+	*memory_free = 0;
+	*memory_cache = 0;
+	*memory_buffers = 0;
+	*swap_total = 0;
+	*swap_free = 0;
+
 	while (found < 6 && fgets (buffer, 1024, file) != NULL)
 	{
 		found += sscanf (buffer, "MemTotal:\t%u kB", memory_total);
@@ -62,7 +69,7 @@ get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
 	gchar buffer[1024];
 	static gulong jiffies_user = 0, jiffies_system = 0, jiffies_total = 0;
 	static gulong jiffies_user_old = 0, jiffies_system_old = 0, jiffies_total_old = 0;
-	gulong user, user_nice, system, idle;
+	gulong user = 0, user_nice = 0, system = 0, idle = 0;
 
 	if ((file = fopen (filename, "r")) == NULL)
 		return FALSE;
@@ -218,7 +225,7 @@ get_task_details (guint pid, Task *task)
 	{
 		gchar dummy[256];
 		gint idummy;
-		gulong jiffies_user, jiffies_system;
+		gulong jiffies_user = 0, jiffies_system = 0;
 		struct passwd *pw;
 		struct stat sstat;
 



More information about the Xfce4-commits mailing list