summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 674032d)
raw | patch | inline | side by side (parent: 674032d)
author | Florian Forster <octo@collectd.org> | |
Tue, 4 Jun 2013 06:35:09 +0000 (08:35 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 4 Jun 2013 06:35:09 +0000 (08:35 +0200) |
The key length is very predicable, so buffer length is not a problem.
src/zfs_arc.c | patch | blob | history |
diff --git a/src/zfs_arc.c b/src/zfs_arc.c
index cd0c8414b114eadb605c1e39a4ace65e1ea92399..6bf7daef7479020a2a024c1eba08b09393c0c2bf 100644 (file)
--- a/src/zfs_arc.c
+++ b/src/zfs_arc.c
typedef void kstat_t;
#endif
-static long long get_zfs_value(void * dummy __unused, const char *kstat_value)
+static long long get_zfs_value(kstat_t *dummy __attribute__((unused)),
+ char const *name)
{
+ char buffer[256];
long long value;
size_t valuelen = sizeof(value);
int rv;
- char *key;
-
- key = ssnprintf_alloc("%s%s", zfs_arcstat, kstat_value);
- if (key != NULL) {
- if (strlen(key) > 0) {
- rv = sysctlbyname(key, (void *)&value, &valuelen, NULL, (size_t)0);
- free(key);
- if (rv == 0)
- return (value);
- } else
- free(key);
- }
+
+ ssnprintf (buffer, sizeof (buffer), "%s%s", zfs_arcstat, name);
+ rv = sysctlbyname (buffer, (void *) &value, &valuelen,
+ /* new value = */ NULL, /* new length = */ (size_t) 0);
+ if (rv == 0)
+ return (value);
return (-1);
}