Code

grpc plugin: Always populate *instance fields in a value-list.
authorSebastian Harl <sh@tokkee.org>
Fri, 6 May 2016 21:47:53 +0000 (23:47 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 30 May 2016 21:44:19 +0000 (23:44 +0200)
That is, ensure a (null-terminated!) empty string if the field is empty.

src/grpc.cc

index a1abe4a292d97cb8256afe475456d046b14c2167..0330aa0d5225c02e7e8852e3c3415e653ac51636 100644 (file)
@@ -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;
                }