From: Sebastian Harl Date: Fri, 6 May 2016 21:47:53 +0000 (+0200) Subject: grpc plugin: Always populate *instance fields in a value-list. X-Git-Tag: collectd-5.6.0~246^2~12 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=f8b9ad9fccdc8fd779fd1be433220bf6bcd59961 grpc plugin: Always populate *instance fields in a value-list. That is, ensure a (null-terminated!) empty string if the field is empty. --- 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; }