From f8b9ad9fccdc8fd779fd1be433220bf6bcd59961 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Fri, 6 May 2016 23:47:53 +0200 Subject: [PATCH] grpc plugin: Always populate *instance fields in a value-list. That is, ensure a (null-terminated!) empty string if the field is empty. --- src/grpc.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/grpc.cc b/src/grpc.cc index a1abe4a2..0330aa0d 100644 --- a/src/grpc.cc +++ b/src/grpc.cc @@ -88,12 +88,10 @@ static grpc::Status unmarshal_value_list(const collectd::types::ValueList &msg, sstrncpy(vl->type, s.c_str(), sizeof(vl->type)); s = msg.plugin_instance(); - if (s.length()) - sstrncpy(vl->plugin_instance, s.c_str(), sizeof(vl->plugin_instance)); + sstrncpy(vl->plugin_instance, s.c_str(), sizeof(vl->plugin_instance)); s = msg.type_instance(); - if (s.length()) - sstrncpy(vl->type_instance, s.c_str(), sizeof(vl->type_instance)); + sstrncpy(vl->type_instance, s.c_str(), sizeof(vl->type_instance)); value_t *values = NULL; size_t values_len = 0; @@ -126,7 +124,7 @@ static grpc::Status unmarshal_value_list(const collectd::types::ValueList &msg, break; default: status = grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, - grpc::string("unkown value type")); + grpc::string("unknown value type")); break; } -- 2.11.0