From: Florian Forster Date: Tue, 21 Nov 2017 09:38:52 +0000 (+0100) Subject: Merge branch 'collectd-5.7' into collectd-5.8 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=65bdbbfb9c6b287de835e5aa81faee8cd864c1e9;p=collectd.git Merge branch 'collectd-5.7' into collectd-5.8 --- 65bdbbfb9c6b287de835e5aa81faee8cd864c1e9 diff --cc src/target_set.c index 33ab96c9,7c02c487..47e2d293 --- a/src/target_set.c +++ b/src/target_set.c @@@ -347,11 -347,17 +347,17 @@@ static int ts_invoke(const data_set_t * if ((new_meta = meta_data_create()) == NULL) { ERROR("Target `set': failed to create replacement metadata."); - return (-ENOMEM); + return -ENOMEM; } - meta_entries = meta_data_toc(data->meta, &meta_toc); - for (int i = 0; i < meta_entries; i++) { + int status = meta_data_toc(data->meta, &meta_toc); + if (status < 0) { + ERROR("Target `set': meta_data_toc failed with status %d.", status); + return status; + } + size_t meta_entries = (size_t)status; + + for (size_t i = 0; i < meta_entries; i++) { const char *key = meta_toc[i]; char *string; int status; @@@ -360,9 -366,9 +366,9 @@@ if (status) { ERROR("Target `set': Unable to get replacement metadata value `%s'.", key); - strarray_free(meta_toc, (size_t)meta_entries); + strarray_free(meta_toc, meta_entries); meta_data_destroy(new_meta); - return (status); + return status; } ts_subst(temp, sizeof(temp), string, &orig); @@@ -376,9 -382,9 +382,9 @@@ status = meta_data_add_string(new_meta, key, temp); if (status) { ERROR("Target `set': Unable to set metadata value `%s'.", key); - strarray_free(meta_toc, (size_t)meta_entries); + strarray_free(meta_toc, meta_entries); meta_data_destroy(new_meta); - return (status); + return status; } }