summaryrefslogtreecommitdiff
blob: 53d53c1a80e0412a73e2de3718ec6ea26a787689 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
--- nload-0.6.0.orig/src/proc.h
+++ nload-0.6.0/src/proc.h
@@ -36,8 +36,8 @@
 	
 	void readLoad( unsigned long& in, unsigned long& out );
 
-	unsigned long totalIn();
-	unsigned long totalOut();
+	long long totalIn();
+	long long totalOut();
 	
 	int getElapsedTime();
 	
@@ -51,7 +51,7 @@
 	
 	char m_ip[16];
 	
-	unsigned long m_total[2];
+	long long m_total[2];
 
 };
 
--- nload-0.6.0.orig/src/status.h
+++ nload-0.6.0/src/status.h
@@ -52,7 +52,7 @@
 		gigabyte = 7
 	};
 	
-	void update( unsigned long, unsigned long );
+	void update( unsigned long, long long);
 	void print( Window&, int, int, status_format traff_format, status_format data_format );
 	void resetTrafficData();
 
--- nload-0.6.0.orig/src/proc.cpp
+++ nload-0.6.0/src/proc.cpp
@@ -126,7 +126,7 @@
 
 void Proc::readLoad( unsigned long& in, unsigned long& out )
 {
-	unsigned long total_new[2] = { 0, 0 };
+	long long total_new[2] = { 0, 0 };
 	int curr_time = 0;
 	struct timeval time;
 
@@ -181,7 +181,7 @@
 			
 			if( ! strcmp( m_dev, dev ) )
 			{
-				sscanf( tmp, "%lu %*u %*u %*u %*u %*u %*u %*u %lu", &total_new[0], &total_new[1] );
+				sscanf( tmp, "%llu %*u %*u %*u %*u %*u %*u %*u %llu", &total_new[0], &total_new[1] );
 				
 				if( total_new[0] > m_total[0] )
 					in = total_new[0] - m_total[0];
@@ -198,7 +198,7 @@
 		}
 	} while( 0 );
 
-	fclose(fd);
+	if (fd != NULL) fclose(fd);
 	
 #endif
 // === End Linux specific network data reading code ===
@@ -513,12 +513,12 @@
 	return m_elapsed_time;
 }
 
-unsigned long Proc::totalIn()
+long long Proc::totalIn()
 {
 	return m_total[0];
 }
 
-unsigned long Proc::totalOut()
+long long Proc::totalOut()
 {
 	return m_total[1];
 }
--- nload-0.6.0.orig/src/status.cpp
+++ nload-0.6.0/src/status.cpp
@@ -30,7 +30,7 @@
 }
 
 //new traffic measurement has been made => update statistics
-void Status::update( unsigned long new_value, unsigned long new_total )
+void Status::update( unsigned long new_value, long long new_total )
 {
 	
 	m_cur = new_value;
@@ -44,7 +44,9 @@
 	 *the /proc/net/dev file
 	 *(the total bytes value reaches 4GB and then switches to 0)
 	 */
-	if( new_total < ( m_total % UINT_MAX ) )
+	if (new_total >= UINT_MAX )
+		m_total = new_total;
+	else if ( new_total < ( m_total % UINT_MAX ) )
 		m_total = ( ( m_total / UINT_MAX ) + 1 ) * UINT_MAX + new_total;
 	else
 		m_total = ( m_total / UINT_MAX ) * UINT_MAX + new_total;