curl_xml: fix 3 small memory leaks
[collectd.git] / src / contextswitch.c
index b53b574..06055ca 100644 (file)
@@ -27,7 +27,7 @@
 # error "No applicable input method."
 #endif
 
-static void cs_submit (unsigned long context_switches)
+static void cs_submit (derive_t context_switches)
 {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
@@ -49,7 +49,7 @@ static int cs_read (void)
        char buffer[64];
        int numfields;
        char *fields[3];
-       unsigned long result = 0;
+       derive_t result = 0;
        int status = -2;
 
        fh = fopen ("/proc/stat", "r");
@@ -64,18 +64,15 @@ static int cs_read (void)
                char *endptr;
 
                numfields = strsplit(buffer, fields, STATIC_ARRAY_SIZE (fields));
-               if (numfields != 2) {
-                       ERROR ("contextswitch plugin: ctxt in /proc/stat "
-                                       "contains more than 2 fields.");
+               if (numfields != 2)
                        continue;
-               }
 
                if (strcmp("ctxt", fields[0]) != 0)
                        continue;
 
                errno = 0;
                endptr = NULL;
-               result = strtoul(fields[1], &endptr, 10);
+               result = (derive_t) strtoll (fields[1], &endptr, /* base = */ 10);
                if ((endptr == fields[1]) || (errno != 0)) {
                        ERROR ("contextswitch plugin: Cannot parse ctxt value: %s",
                                        fields[1]);