From bec423a136b879dc53e9123f7e8b94c7ef6097a2 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 29 Sep 2010 17:04:53 +0200 Subject: [PATCH] contextswitch plugin: Some coding style changes. --- src/contextswitch.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/contextswitch.c b/src/contextswitch.c index f571d39c..c207318f 100644 --- a/src/contextswitch.c +++ b/src/contextswitch.c @@ -59,29 +59,31 @@ static void cs_submit (derive_t context_switches) static int cs_read (void) { - int status = -2; #if HAVE_SYSCTLBYNAME - int value; + int value = 0; size_t value_len = sizeof (value); + int status; - if (sysctlbyname ("vm.stats.sys.v_swtch", (void *) &value, &value_len, - NULL, 0) == 0) - { - cs_submit(value); - status = 0; - } - else + status = sysctlbyname ("vm.stats.sys.v_swtch", + &value, &value_len, + /* new pointer = */ NULL, /* new length = */ 0); + if (status != 0) { - ERROR("contextswitch plugin: sysctlbyname failed"); + ERROR("contextswitch plugin: sysctlbyname " + "(vm.stats.sys.v_swtch) failed"); + return (-1); } + cs_submit (value); /* #endif HAVE_SYSCTLBYNAME */ + #elif KERNEL_LINUX FILE *fh; char buffer[64]; int numfields; char *fields[3]; derive_t result = 0; + int status = -2; fh = fopen ("/proc/stat", "r"); if (fh == NULL) { -- 2.30.2