*
**************************************************************************/
-#if HAVE_GALLIUM_EXTRA_HUD
+#ifdef HAVE_GALLIUM_EXTRA_HUD
/* Purpose: Reading network interface RX/TX throughput per second,
* displaying on the HUD.
#include "hud/hud_private.h"
#include "util/list.h"
-#include "os/os_time.h"
+#include "util/os_time.h"
#include "os/os_thread.h"
#include "util/u_memory.h"
+#include "util/u_string.h"
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
memset(&stats, 0, sizeof(stats));
memset(&req, 0, sizeof(req));
- strcpy(req.ifr_name, nic->name);
+ snprintf(req.ifr_name, sizeof(req.ifr_name), "%s", nic->name);
req.u.data.pointer = &stats;
req.u.data.flags = 1;
req.u.data.length = sizeof(struct iw_statistics);
memset(&stats, 0, sizeof(stats));
memset(&req, 0, sizeof(req));
- strcpy(req.ifr_name, nic->name);
+ snprintf(req.ifr_name, sizeof(req.ifr_name), "%s", nic->name);
req.u.data.pointer = &stats;
req.u.data.flags = 1;
req.u.data.length = sizeof(struct iw_statistics);
}
static void
-query_nic_load(struct hud_graph *gr)
+query_nic_load(struct hud_graph *gr, struct pipe_context *pipe)
{
/* The framework calls us at a regular but indefined period,
* not once per second, compensate the statistics accordingly.
((bytes - nic->last_nic_bytes) / 1000000) * 8;
float speedMbps = nic->speedMbps;
- float periodMs = gr->pane->period / 1000;
+ float periodMs = gr->pane->period / 1000.0;
float bits = nic_mbps;
float period_factor = periodMs / 1000;
float period_speed = speedMbps * period_factor;
float pct = (bits / period_speed) * 100;
/* Scaling bps with a narrow time period into a second,
- * potentially suffers from routing errors at higher
+ * potentially suffers from rounding errors at higher
* periods. Eg 104%. Compensate.
*/
if (pct > 100)
}
else if (nic->mode == NIC_RSSI_DBM)
snprintf(gr->name, sizeof(gr->name), "%s-rssi", nic->name);
- else
+ else {
+ free(gr);
return;
+ }
gr->query_data = nic;
gr->query_new_value = query_nic_load;