summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1e648d4)
raw | patch | inline | side by side (parent: 1e648d4)
author | Florian Forster <octo@collectd.org> | |
Thu, 6 Sep 2012 14:12:53 +0000 (16:12 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 6 Sep 2012 14:12:53 +0000 (16:12 +0200) |
Rather than asserting that an argument is not NULL, check this condition
and return an error code.
This should fix Github issue #71.
and return an error code.
This should fix Github issue #71.
src/common.c | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index 3bab7a59421466d33fbc072cc563e08c2f8248a7..f201b4071fcd8e9a496d8ff8ffe4036b8ae42160 100644 (file)
--- a/src/common.c
+++ b/src/common.c
kstat_named_t *kn;
long long retval = -1LL;
-#ifdef assert
- assert (ksp != NULL);
- assert (ksp->ks_type == KSTAT_TYPE_NAMED);
-#else
if (ksp == NULL)
{
- ERROR ("ERROR: %s:%i: ksp == NULL\n", __FILE__, __LINE__);
+ ERROR ("get_kstat_value (\"%s\"): ksp is NULL.", name)
return (-1LL);
}
else if (ksp->ks_type != KSTAT_TYPE_NAMED)
{
- ERROR ("ERROR: %s:%i: ksp->ks_type != KSTAT_TYPE_NAMED\n", __FILE__, __LINE__);
+ ERROR ("get_kstat_value (\"%s\"): ksp->ks_type (%#x) "
+ "is not KSTAT_TYPE_NAMED (%#x).",
+ name,
+ (unsigned int) ksp->ks_type,
+ (unsigned int) KSTAT_TYPE_NAMED);
return (-1LL);
}
-#endif
if ((kn = (kstat_named_t *) kstat_data_lookup (ksp, name)) == NULL)
- return (retval);
+ return (-1LL);
if (kn->data_type == KSTAT_DATA_INT32)
retval = (long long) kn->value.i32;