[Asterisk-code-review] CLI: Fix 'core show sysinfo' function ordering. (asterisk[13])

Corey Farrell asteriskteam at digium.com
Mon Dec 11 19:41:44 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7517


Change subject: CLI: Fix 'core show sysinfo' function ordering.
......................................................................

CLI: Fix 'core show sysinfo' function ordering.

Handle CLI initialization before any processing occurs.

Change-Id: I598b911d2e409214bbdfd0ba0882be1d602d221c
---
M main/asterisk.c
1 file changed, 21 insertions(+), 17 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/17/7517/1

diff --git a/main/asterisk.c b/main/asterisk.c
index 7edf66f..2e06f19 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -801,6 +801,27 @@
 	int totalswap = 0;
 #if defined(HAVE_SYSINFO)
 	struct sysinfo sys_info;
+#elif defined(HAVE_SYSCTL)
+	static int pageshift;
+	struct vmtotal vmtotal;
+	struct timeval	boottime;
+	time_t	now;
+	int mib[2], pagesize, usedswap = 0;
+	size_t len;
+#endif
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "core show sysinfo";
+		e->usage =
+			"Usage: core show sysinfo\n"
+			"       List current system information.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+#if defined(HAVE_SYSINFO)
 	sysinfo(&sys_info);
 	uptime = sys_info.uptime / 3600;
 	physmem = sys_info.totalram * sys_info.mem_unit;
@@ -809,12 +830,6 @@
 	freeswap = (sys_info.freeswap * sys_info.mem_unit) / 1024;
 	nprocs = sys_info.procs;
 #elif defined(HAVE_SYSCTL)
-	static int pageshift;
-	struct vmtotal vmtotal;
-	struct timeval	boottime;
-	time_t	now;
-	int mib[2], pagesize, usedswap = 0;
-	size_t len;
 	/* calculate the uptime by looking at boottime */
 	time(&now);
 	mib[0] = CTL_KERN;
@@ -861,17 +876,6 @@
 	sysctl(mib, 2, &nprocs, &len, NULL, 0);
 #endif
 #endif
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "core show sysinfo";
-		e->usage =
-			"Usage: core show sysinfo\n"
-			"       List current system information.\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
 
 	ast_cli(a->fd, "\nSystem Statistics\n");
 	ast_cli(a->fd, "-----------------\n");

-- 
To view, visit https://gerrit.asterisk.org/7517
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I598b911d2e409214bbdfd0ba0882be1d602d221c
Gerrit-Change-Number: 7517
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171211/ca01d44f/attachment.html>


More information about the asterisk-code-review mailing list