aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-06-02 11:11:43 +0200
committerBjörn-Egil Dahlberg <[email protected]>2015-06-02 11:11:43 +0200
commit5dc2cc80ee62c8c7da2775b56e9ed5e1f30eb940 (patch)
tree353b1170f562b6ceed6518ca6649fa2d9a51da7c /lib
parent3de8be10b12bcf8520cc1ec58ae4f8d123b7fe2f (diff)
downloadotp-5dc2cc80ee62c8c7da2775b56e9ed5e1f30eb940.tar.gz
otp-5dc2cc80ee62c8c7da2775b56e9ed5e1f30eb940.tar.bz2
otp-5dc2cc80ee62c8c7da2775b56e9ed5e1f30eb940.zip
os_mon: Comply with C89 standard
Diffstat (limited to 'lib')
-rw-r--r--lib/os_mon/c_src/cpu_sup.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/os_mon/c_src/cpu_sup.c b/lib/os_mon/c_src/cpu_sup.c
index b81a5cd1ad..9e217db105 100644
--- a/lib/os_mon/c_src/cpu_sup.c
+++ b/lib/os_mon/c_src/cpu_sup.c
@@ -543,36 +543,37 @@ static void util_measure(unsigned int **result_vec, int *result_sz) {
#if defined(__FreeBSD__)
#define EXIT_WITH(msg) (rich_error(msg, __FILE__, __LINE__))
+#define RICH_BUFLEN (213) /* left in error(char*) */
void rich_error(const char *reason, const char *file, const int line) {
- const size_t buflen = 213; // left in error(char*)
- char buf[buflen];
- snprintf(buf, buflen, "%s (%s:%i)", reason, file, line);
+ char buf[RICH_BUFLEN];
+ snprintf(buf, RICH_BUFLEN, "%s (%s:%i)", reason, file, line);
error(buf);
}
-
+#undef RICH_BUFLEN
static void util_measure(unsigned int **result_vec, int *result_sz) {
int no_of_cpus;
- getsysctl("hw.ncpu", &no_of_cpus, sizeof(int));
+ size_t size_cpu_times;
+ unsigned long *cpu_times;
+ unsigned int *rv = NULL;
+ int i;
- // Header constant CPUSTATES = #long values per cpu.
- size_t size_cpu_times = sizeof(long) * CPUSTATES * no_of_cpus;
- unsigned long *cpu_times = malloc(size_cpu_times);
+ getsysctl("hw.ncpu", &no_of_cpus, sizeof(int));
+ /* Header constant CPUSTATES = #long values per cpu. */
+ size_cpu_times = sizeof(long) * CPUSTATES * no_of_cpus;
+ cpu_times = malloc(size_cpu_times);
if (!cpu_times) {
EXIT_WITH("badalloc");
}
getsysctl("kern.cp_times", cpu_times, size_cpu_times);
- unsigned int *rv = NULL;
-
rv = *result_vec;
rv[0] = no_of_cpus;
rv[1] = CU_BSD_VALUES;
++rv; /* first value is number of cpus */
++rv; /* second value is number of entries */
- int i;
for (i = 0; i < no_of_cpus; ++i) {
int offset = i * CPUSTATES;
rv[ 0] = CU_CPU_ID; rv[ 1] = i;