diff options
author | Heikki Kallasjoki <fis@zem.fi> | 2018-12-07 02:12:32 +0000 |
---|---|---|
committer | Heikki Kallasjoki <fis+github@zem.fi> | 2018-12-07 02:17:55 +0000 |
commit | 7ec8aa9fcfba92019f537cd19dac4ce15674ddd6 (patch) | |
tree | edfdfcb09dd20e54f9cd4742346c1bf8a45e60d2 /uname.c | |
parent | 16d61af28bcd07348117fd457b62ff39c1a0b45d (diff) | |
download | nano-exporter-7ec8aa9fcfba92019f537cd19dac4ce15674ddd6.tar.gz nano-exporter-7ec8aa9fcfba92019f537cd19dac4ce15674ddd6.tar.xz nano-exporter-7ec8aa9fcfba92019f537cd19dac4ce15674ddd6.zip |
Use a struct type for metric labels.
Resolves #4. The real readability benefits are for test code, which will follow up in due course.
Diffstat (limited to 'uname.c')
-rw-r--r-- | uname.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/uname.c b/uname.c index 56267c3..2ea5f92 100644 --- a/uname.c +++ b/uname.c @@ -40,7 +40,7 @@ enum { }; struct uname_context { - const char *labels[max_label + 1][2]; + struct label labels[max_label + 1]; }; static void *uname_init(int argc, char *argv[]) { @@ -53,17 +53,17 @@ static void *uname_init(int argc, char *argv[]) { } struct uname_context *ctx = must_malloc(sizeof *ctx); - ctx->labels[label_machine][0] = "machine"; - ctx->labels[label_machine][1] = must_strdup(name.machine); - ctx->labels[label_nodename][0] = "nodename"; - ctx->labels[label_nodename][1] = must_strdup(name.nodename); - ctx->labels[label_release][0] = "release"; - ctx->labels[label_release][1] = must_strdup(name.release); - ctx->labels[label_sysname][0] = "sysname"; - ctx->labels[label_sysname][1] = must_strdup(name.sysname); - ctx->labels[label_version][0] = "version"; - ctx->labels[label_version][1] = must_strdup(name.version); - ctx->labels[max_label][0] = ctx->labels[max_label][1] = 0; + ctx->labels[label_machine].key = "machine"; + ctx->labels[label_machine].value = must_strdup(name.machine); + ctx->labels[label_nodename].key = "nodename"; + ctx->labels[label_nodename].value = must_strdup(name.nodename); + ctx->labels[label_release].key = "release"; + ctx->labels[label_release].value = must_strdup(name.release); + ctx->labels[label_sysname].key = "sysname"; + ctx->labels[label_sysname].value = must_strdup(name.sysname); + ctx->labels[label_version].key = "version"; + ctx->labels[label_version].value = must_strdup(name.version); + ctx->labels[max_label].key = ctx->labels[max_label].value = 0; return ctx; } |