summary refs log tree commit diff stats
path: root/plugins
diff options
context:
space:
mode:
authorArnavion <arnavion@gmail.com>2015-02-21 17:28:56 -0800
committerArnavion <arnavion@gmail.com>2015-02-21 17:28:56 -0800
commitc1d06c7d633ad0edc1ac8f63200f7f12a96d9f56 (patch)
tree5f42260b23e4325223061e39987ebbc454d88f62 /plugins
parent5e3355a6c348b511c7b7a1f6dc89185726d566c5 (diff)
Fixed cast warning, use of uninitialized buffer and whitespace.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sysinfo/format.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/plugins/sysinfo/format.c b/plugins/sysinfo/format.c
index f0b0effd..741c43e2 100644
--- a/plugins/sysinfo/format.c
+++ b/plugins/sysinfo/format.c
@@ -23,39 +23,34 @@ char *
 sysinfo_format_uptime (gint64 uptime)
 {
 	char buffer[128];
-	int weeks;
-	int days;
-	int hours;
-	int minutes;
-	int seconds;
 
-	seconds = uptime%60;
-	minutes = (uptime/60)%60;
-	hours   = (uptime/3600)%24;
-	days    = (uptime/86400)%7;
-	weeks   = uptime/604800;
+	gint64 weeks = uptime / 604800;
+	int days     = (uptime / 86400) % 7;
+	int hours    = (uptime / 3600) % 24;
+	int minutes  = (uptime / 60) % 60;
+	int seconds  = uptime % 60;
 
-	if (minutes != 0 || hours != 0 || days != 0 || weeks != 0)
+	if (weeks != 0)
 	{
-		if (hours != 0 || days != 0 || weeks != 0)
-		{
-			if (days !=0 || weeks != 0)
-			{
-				if (weeks != 0)
-					g_snprintf (buffer, sizeof(buffer), "%dw %dd %dh %dm %ds", weeks, days, hours, minutes, seconds);
-				else
-					g_snprintf (buffer, sizeof(buffer), "%dd %dh %dm %ds", days, hours, minutes, seconds);
-			}
-			else
-			{
-				g_snprintf (buffer, sizeof(buffer), "%dh %dm %ds", hours, minutes, seconds);
-			}
-		}
-		else
-		{
-			g_snprintf (buffer, sizeof(buffer), "%dm %ds", minutes, seconds);
-		}
+		g_snprintf (buffer, sizeof(buffer), "%" G_GINT64_FORMAT "w %dd %dh %dm %ds", weeks, days, hours, minutes, seconds);
 	}
+	else if (days != 0)
+	{
+		g_snprintf (buffer, sizeof(buffer), "%dd %dh %dm %ds", days, hours, minutes, seconds);
+	}
+	else if (hours != 0)
+	{
+		g_snprintf (buffer, sizeof(buffer), "%dh %dm %ds", hours, minutes, seconds);
+	}
+	else if (minutes != 0)
+	{
+		g_snprintf (buffer, sizeof(buffer), "%dm %ds", minutes, seconds);
+	}
+	else
+	{
+		g_snprintf (buffer, sizeof(buffer), "%ds", seconds);
+	}
+
 	return g_strdup (buffer);
 }