- result = strtoul(fields[1], NULL, 10);
- if (errno == ERANGE && result == ULONG_MAX) {
- ERROR ("contextswitch plugin: ctxt value in /proc/stat overflows.");
+ errno = 0;
+ endptr = NULL;
+ 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]);
+ status = -1;