gallium: pass cso_velems_state into cso_context instead of pipe_vertex_element
[mesa.git] / src / gallium / auxiliary / hud / hud_nic.c
index 5fab3319db2862a062f0a2e28ec84c8e0edcb5af..b10247e44751344e7465025600ed339e9916d0f8 100644 (file)
@@ -37,6 +37,7 @@
 #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>
@@ -114,7 +115,7 @@ query_wifi_bitrate(const struct nic_info *nic, uint64_t *bitrate)
    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);
@@ -145,7 +146,7 @@ query_nic_rssi(const struct nic_info *nic, uint64_t *leveldBm)
    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);
@@ -192,14 +193,14 @@ query_nic_load(struct hud_graph *gr, struct pipe_context *pipe)
                   ((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)