From ab6e141f3167667e26488b661da7f738188583b7 Mon Sep 17 00:00:00 2001 From: "Leandro A. F. Pereira" Date: Thu, 15 Nov 2007 16:17:11 +0000 Subject: Fix bytes received/sent overflow in 'Network Interfaces' --- hardinfo2/arch/linux/common/net.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'hardinfo2/arch/linux/common') diff --git a/hardinfo2/arch/linux/common/net.h b/hardinfo2/arch/linux/common/net.h index 527da1df..2a89529c 100644 --- a/hardinfo2/arch/linux/common/net.h +++ b/hardinfo2/arch/linux/common/net.h @@ -147,13 +147,13 @@ scan_net_interfaces_24(void) NetInfo ni; gchar buffer[256]; gchar *devid, *detailed; - gulong recv_bytes; - gulong recv_errors; - gulong recv_packets; + gdouble recv_bytes; + gdouble recv_errors; + gdouble recv_packets; - gulong trans_bytes; - gulong trans_errors; - gulong trans_packets; + gdouble trans_bytes; + gdouble trans_errors; + gdouble trans_packets; if (!g_file_test("/proc/net/dev", G_FILE_TEST_EXISTS)) { if (network_interfaces) { @@ -196,21 +196,21 @@ scan_net_interfaces_24(void) buf = strchr(buf, ':') + 1; /* iface: bytes packets errs drop fifo frame compressed multicast */ - sscanf(buf, "%ld %ld %ld %d %d %d %d %d %ld %ld %ld", + sscanf(buf, "%lf %lf %lf %d %d %d %d %d %lf %lf %lf", &recv_bytes, &recv_packets, &recv_errors, &trash, &trash, &trash, &trash, &trash, &trans_bytes, &trans_packets, &trans_errors); - gfloat recv_mb = recv_bytes / 1048576.0; - gfloat trans_mb = trans_bytes / 1048576.0; + gdouble recv_mb = recv_bytes / 1048576.0; + gdouble trans_mb = trans_bytes / 1048576.0; get_net_info(ifacename, &ni); devid = g_strdup_printf("NET%s", ifacename); ip = g_strdup_printf(" (%s)", ni.ip); - network_interfaces = h_strdup_cprintf("$%s$%s=Sent %.2fMiB, received %.2fMiB%s\n", + network_interfaces = h_strdup_cprintf("$%s$%s=Sent %.2lfMiB, received %.2lfMiB%s\n", network_interfaces, devid, ifacename, @@ -229,8 +229,8 @@ scan_net_interfaces_24(void) "Hardware Address (MAC)=%02x:%02x:%02x:%02x:%02x:%02x\n" "MTU=%d\n" "[Transfer Details]\n" - "Bytes Received=%ld (%.2fMiB)\n" - "Bytes Sent=%ld (%.2fMiB)\n", + "Bytes Received=%.0lf (%.2fMiB)\n" + "Bytes Sent=%.0lf (%.2fMiB)\n", iface_type, ni.mac[0], ni.mac[1], ni.mac[2], ni.mac[3], -- cgit v1.2.3