[Xfce4-commits] <xfce4-systemload-plugin:master> Eliminated warnings.
Mike Massonnet
noreply at xfce.org
Sun Jan 22 11:06:05 CET 2012
Updating branch refs/heads/master
to 9d7f39c86c656a9ae14c3f297f682e86c60941cd (commit)
from e91609c52c767b8354d129601ae4e3b66d888e75 (commit)
commit 9d7f39c86c656a9ae14c3f297f682e86c60941cd
Author: David Schneider <dnschneid at gmail.com>
Date: Fri Jan 20 23:17:48 2012 -0800
Eliminated warnings.
panel-plugin/cpu.c | 16 ++++++++--------
panel-plugin/memswap.c | 25 ++++++++++++-------------
panel-plugin/systemload.c | 2 --
panel-plugin/uptime.c | 7 ++++---
4 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c
index bc950f7..28cf561 100644
--- a/panel-plugin/cpu.c
+++ b/panel-plugin/cpu.c
@@ -51,10 +51,10 @@ struct cpu_load_struct {
gulong cpu_used, oldtotal, oldused;
-gulong read_cpuload()
+gulong read_cpuload(void)
{
FILE *fd;
- uint64_t user, nice, system, idle, iowait, irq, softirq, guest;
+ unsigned long long int user, unice, usystem, idle, iowait, irq, softirq, guest;
gulong used, total;
int nb_read;
@@ -65,8 +65,8 @@ gulong read_cpuload()
}
/* Don't count steal time. It is neither busy nor free tiime. */
- nb_read = fscanf (fd, "%*s " "%llu %llu %llu %llu %llu %llu %llu %*llu %llu",
- &user, &nice, &system, &idle, &iowait, &irq, &softirq, &guest);
+ nb_read = fscanf (fd, "%*s %llu %llu %llu %llu %llu %llu %llu %*u %llu",
+ &user, &unice, &usystem, &idle, &iowait, &irq, &softirq, &guest);
fclose(fd);
switch (nb_read) /* fall through intentional */
{
@@ -80,7 +80,7 @@ gulong read_cpuload()
guest = 0;
}
- used = user + nice + system + irq + softirq + guest;
+ used = user + unice + usystem + irq + softirq + guest;
total = used + idle + iowait;
if ((total - oldtotal) != 0)
@@ -118,7 +118,7 @@ struct cpu_load_struct {
gulong cpu_used, oldtotal, oldused;
-gulong read_cpuload()
+gulong read_cpuload(void)
{
gulong used, total;
long cp_time[CPUSTATES];
@@ -170,7 +170,7 @@ struct cpu_load_struct {
gulong cpu_used, oldtotal, oldused;
-gulong read_cpuload()
+gulong read_cpuload(void)
{
gulong used, total;
static int mib[] = { CTL_KERN, KERN_CP_TIME };
@@ -224,7 +224,7 @@ struct cpu_load_struct {
gulong cpu_used, oldtotal, oldused;
-gulong read_cpuload()
+gulong read_cpuload(void)
{
gulong used, total;
static int mib[] = { CTL_KERN, KERN_CPTIME };
diff --git a/panel-plugin/memswap.c b/panel-plugin/memswap.c
index afa5fb6..d671686 100644
--- a/panel-plugin/memswap.c
+++ b/panel-plugin/memswap.c
@@ -59,7 +59,6 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT, gulong *MU, gulong *ST,
{
int fd;
size_t n;
- int o_MTotal, o_MFree, o_MBuffers, o_MCached, o_STotal, o_SFree;
char *b_MTotal, *b_MFree, *b_MBuffers, *b_MCached, *b_STotal, *b_SFree;
if ((fd = open("/proc/meminfo", O_RDONLY)) < 0)
@@ -78,28 +77,28 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT, gulong *MU, gulong *ST,
MemInfoBuf[n] = '\0';
b_MTotal = strstr(MemInfoBuf, "MemTotal");
- if (b_MTotal)
- o_MTotal = sscanf(b_MTotal + strlen("MemTotal"), ": %lu", &MTotal);
+ if (!b_MTotal || !sscanf(b_MTotal + strlen("MemTotal"), ": %lu", &MTotal))
+ return -1;
b_MFree = strstr(MemInfoBuf, "MemFree");
- if (b_MFree)
- o_MFree = sscanf(b_MFree + strlen("MemFree"), ": %lu", &MFree);
+ if (!b_MFree || !sscanf(b_MFree + strlen("MemFree"), ": %lu", &MFree))
+ return -1;
b_MBuffers = strstr(MemInfoBuf, "Buffers");
- if (b_MBuffers)
- o_MBuffers = sscanf(b_MBuffers + strlen("Buffers"), ": %lu", &MBuffers);
+ if (!b_MBuffers || !sscanf(b_MBuffers + strlen("Buffers"), ": %lu", &MBuffers))
+ return -1;
b_MCached = strstr(MemInfoBuf, "Cached");
- if (b_MCached)
- o_MCached = sscanf(b_MCached + strlen("Cached"), ": %lu", &MCached);
+ if (!b_MCached || !sscanf(b_MCached + strlen("Cached"), ": %lu", &MCached))
+ return -1;
b_STotal = strstr(MemInfoBuf, "SwapTotal");
- if (b_STotal)
- o_STotal = sscanf(b_STotal + strlen("SwapTotal"), ": %lu", &STotal);
+ if (!b_STotal || !sscanf(b_STotal + strlen("SwapTotal"), ": %lu", &STotal))
+ return -1;
b_SFree = strstr(MemInfoBuf, "SwapFree");
- if (b_SFree)
- o_SFree = sscanf(b_SFree + strlen("SwapFree"), ": %lu", &SFree);
+ if (!b_SFree || !sscanf(b_SFree + strlen("SwapFree"), ": %lu", &SFree))
+ return -1;
MFree += MCached + MBuffers;
MUsed = MTotal - MFree;
diff --git a/panel-plugin/systemload.c b/panel-plugin/systemload.c
index a0f358f..92e0f4b 100644
--- a/panel-plugin/systemload.c
+++ b/panel-plugin/systemload.c
@@ -118,8 +118,6 @@ update_monitors(t_global_monitor *global)
{
if (global->monitor[count]->history[0] > 100)
global->monitor[count]->history[0] = 100;
- else if (global->monitor[count]->history[0] < 0)
- global->monitor[count]->history[0] = 0;
global->monitor[count]->value_read =
(global->monitor[count]->history[0] +
diff --git a/panel-plugin/uptime.c b/panel-plugin/uptime.c
index 33fd4c6..0de895d 100644
--- a/panel-plugin/uptime.c
+++ b/panel-plugin/uptime.c
@@ -43,7 +43,7 @@
#define PROC_UPTIME "/proc/uptime"
-gulong read_uptime()
+gulong read_uptime(void)
{
FILE *fd;
gulong uptime;
@@ -53,7 +53,8 @@ gulong read_uptime()
g_warning(_("File /proc/uptime not found!"));
return 0;
}
- fscanf(fd, "%lu", &uptime);
+ if (!fscanf(fd, "%lu", &uptime))
+ uptime = 0;
fclose(fd);
return uptime;
@@ -88,7 +89,7 @@ gulong read_uptime()
#include <sys/time.h>
#endif /* !__FreeBSD__ */
-gulong read_uptime()
+gulong read_uptime(void)
{
int mib[2] = {CTL_KERN, KERN_BOOTTIME};
struct timeval boottime;
More information about the Xfce4-commits
mailing list