Skip to contentSkip to conversation

docs/cpu-load: format the example code.

PATCH In review Hui Su 2 participants 2 messages Oct 18, 2020 – Oct 21, 2020 Documentation

lore
Share & tools
lore

Hui Su

author
#0 lore raw

PATCH 1/1 docs/cpu-load: format the example code.

format the example code.

---
 Documentation/admin-guide/cpu-load.rst | 63 ++++++++++++++------------
 1 file changed, 33 insertions(+), 30 deletions(-)
Documentation/admin-guide/cpu-load.rst +33 -30
index ebdecf864080..f3ada90e9ca8 100644
@@ -61,43 +61,46 @@ will lead to quite erratic information inside ``/proc/stat``::
 
 	static volatile sig_atomic_t stop;
 
-	static void sighandler (int signr)
+	static void sighandler(int signr)
 	{
-	(void) signr;
-	stop = 1;
+		(void) signr;
+		stop = 1;
 	}
+
 	static unsigned long hog (unsigned long niters)
 	{
-	stop = 0;
-	while (!stop && --niters);
-	return niters;
+		stop = 0;
+		while (!stop && --niters);
+		return niters;
 	}
+
 	int main (void)
 	{
-	int i;
-	struct itimerval it = { .it_interval = { .tv_sec = 0, .tv_usec = 1 },
-				.it_value = { .tv_sec = 0, .tv_usec = 1 } };
-	sigset_t set;
-	unsigned long v[HIST];
-	double tmp = 0.0;
-	unsigned long n;
-	signal (SIGALRM, &sighandler);
-	setitimer (ITIMER_REAL, &it, NULL);
-
-	hog (ULONG_MAX);
-	for (i = 0; i < HIST; ++i) v[i] = ULONG_MAX - hog (ULONG_MAX);
-	for (i = 0; i < HIST; ++i) tmp += v[i];
-	tmp /= HIST;
-	n = tmp - (tmp / 3.0);
-
-	sigemptyset (&set);
-	sigaddset (&set, SIGALRM);
-
-	for (;;) {
-		hog (n);
-		sigwait (&set, &i);
-	}
-	return 0;
+		int i;
+		struct itimerval it = {
+			.it_interval = { .tv_sec = 0, .tv_usec = 1 },
+			.it_value    = { .tv_sec = 0, .tv_usec = 1 } };
+		sigset_t set;
+		unsigned long v[HIST];
+		double tmp = 0.0;
+		unsigned long n;
+		signal(SIGALRM, &sighandler);
+		setitimer(ITIMER_REAL, &it, NULL);
+
+		hog (ULONG_MAX);
+		for (i = 0; i < HIST; ++i) v[i] = ULONG_MAX - hog(ULONG_MAX);
+		for (i = 0; i < HIST; ++i) tmp += v[i];
+		tmp /= HIST;
+		n = tmp - (tmp / 3.0);
+
+		sigemptyset(&set);
+		sigaddset(&set, SIGALRM);
+
+		for (;;) {
+			hog(n);
+			sigwait(&set, &i);
+		}
+		return 0;
 	}
 
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 6 lines · On Mon, 19 Oct 2020 01:05:57 +0800 Hui Su <[email protected]> wrote:

format the example code.

---
 Documentation/admin-guide/cpu-load.rst | 63 ++++++++++++++------------
 1 file changed, 33 insertions(+), 30 deletions(-)

Hmm...this document wasn't always that way; it looks like maybe the code got mangled during the RST conversion.

I question the value of this document in general...but as long as we have it the code might as well look right, so I've applied this, thanks.

jon