Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Set vl.host in plugin_dispatch_values() #1951

Closed
octo opened this issue Sep 21, 2016 · 1 comment
Closed

RFC: Set vl.host in plugin_dispatch_values() #1951

octo opened this issue Sep 21, 2016 · 1 comment

Comments

@octo
Copy link
Member

octo commented Sep 21, 2016

Currently, most plugins do something like the following to submit metrics:

value_list_t vl = VALUE_LIST_INIT;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
plugin_dispatch_values (&vl);

The sstrncpy() line is needed, because the VALUE_LIST_INIT cannot properly initialize the char host[128] field using hostname_g:

plugin.c:158:2: error: missing braces around initializer [-Werror=missing-braces]
  value_list_t vl = VALUE_LIST_INIT;
  ^
plugin.c:158:2: error: (near initialization for ‘vl.host’) [-Werror=missing-braces]
plugin.c:158:2: error: initialization makes integer from pointer without a cast [-Werror]
plugin.c:158:2: error: (near initialization for ‘vl.host[0]’) [-Werror]
plugin.c:158:2: error: initialization makes integer from pointer without a cast [-Werror]

I propose to add code along the lines of:

if (strlen (vl->host) == 0) {
  sstrncpy (vl->host, hostname_g, sizeof (vl->host));
}

to plugin_write_enqueue(), therefore removing the need for ~115 plugins to initialize this field themselves. Eventually, the same technique could be used to set the vl.plugin field, too (see #1949).

@rpv-tomsk
Copy link
Contributor

I see no reasons against this improvement.

vmytnykx added a commit to elfiesmelfie/collectd that referenced this issue Oct 4, 2016
If old YAJL version is installed on a system (ver < 2.0), the OVS plugin
compilation will fail as it requires tree API to be supported in YAJL
library. For this reason, it was decided to change 'configure' script
to detect YAJL tree API also.

Clean-up according updated collectd style:
  collectd#1931
  collectd#1951

Change-Id: I90c82cdc9780ee8c0c9b794986662a39a5ab0011
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
vmytnykx added a commit to elfiesmelfie/collectd that referenced this issue Dec 6, 2016
If old YAJL version is installed on a system (ver < 2.0), the OVS plugin
compilation will fail as it requires tree API to be supported in YAJL
library. For this reason, it was decided to change 'configure' script
to detect YAJL tree API also.

Clean-up according updated collectd style:
  collectd#1931
  collectd#1951

Change-Id: I90c82cdc9780ee8c0c9b794986662a39a5ab0011
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
vmytnykx added a commit to elfiesmelfie/collectd that referenced this issue Dec 26, 2016
If old YAJL version is installed on a system (ver < 2.0), the OVS plugin
compilation will fail as it requires tree API to be supported in YAJL
library. For this reason, it was decided to change 'configure' script
to detect YAJL tree API also.

Clean-up according updated collectd style:
  collectd#1931
  collectd#1951

Change-Id: I90c82cdc9780ee8c0c9b794986662a39a5ab0011
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants