mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-25 02:32:27 -05:00
Fixed cast warning, use of uninitialized buffer and whitespace.
This commit is contained in:
parent
5e3355a6c3
commit
c1d06c7d63
@ -23,39 +23,34 @@ char *
|
|||||||
sysinfo_format_uptime (gint64 uptime)
|
sysinfo_format_uptime (gint64 uptime)
|
||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
int weeks;
|
|
||||||
int days;
|
|
||||||
int hours;
|
|
||||||
int minutes;
|
|
||||||
int seconds;
|
|
||||||
|
|
||||||
seconds = uptime%60;
|
gint64 weeks = uptime / 604800;
|
||||||
minutes = (uptime/60)%60;
|
int days = (uptime / 86400) % 7;
|
||||||
hours = (uptime/3600)%24;
|
int hours = (uptime / 3600) % 24;
|
||||||
days = (uptime/86400)%7;
|
int minutes = (uptime / 60) % 60;
|
||||||
weeks = uptime/604800;
|
int seconds = uptime % 60;
|
||||||
|
|
||||||
if (minutes != 0 || hours != 0 || days != 0 || weeks != 0)
|
if (weeks != 0)
|
||||||
{
|
{
|
||||||
if (hours != 0 || days != 0 || weeks != 0)
|
g_snprintf (buffer, sizeof(buffer), "%" G_GINT64_FORMAT "w %dd %dh %dm %ds", weeks, days, hours, minutes, seconds);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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);
|
return g_strdup (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user