- INFO("%s: HugePages config key='%s', val='%s'", g_plugin_name, key, val);
+ DEBUG("%s: HugePages config key='%s', val='%s'", g_plugin_name, key, val);
if (strcasecmp(key, g_cfg_rpt_numa) == 0) {
g_flag_rpt_numa = IS_TRUE(val);
if (strcasecmp(key, g_cfg_rpt_numa) == 0) {
g_flag_rpt_numa = IS_TRUE(val);
static void submit_hp(const char *plug_inst, const char *type,
const char *type_instance, gauge_t free_value, gauge_t used_value)
{
static void submit_hp(const char *plug_inst, const char *type,
const char *type_instance, gauge_t free_value, gauge_t used_value)
{
-
- values[0].gauge = free_value;
- values[1].gauge = used_value;
+ value_t values[] = {
+ { .gauge = free_value },
+ { .gauge = used_value },
+ };
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, g_plugin_name, sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plug_inst, sizeof (vl.plugin_instance));
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, g_plugin_name, sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plug_inst, sizeof (vl.plugin_instance));
- if (pathconf(path, _PC_NAME_MAX) == -1) {
- /* Limit not defined, or error */
- ERROR("%s: pathconf failed", g_plugin_name);
- closedir(dir);
- return -1;
+ errno = 0;
+ if ((lim = pathconf(path, _PC_NAME_MAX)) == -1) {
+ /* Limit not defined if errno == 0, otherwise error */
+ if (errno != 0) {
+ ERROR("%s: pathconf failed", g_plugin_name);
+ closedir(dir);
+ return -1;
+ } else {
+ lim = PATH_MAX;
+ }
}
/* read "hugepages-XXXXXkB" entries */
while ((result = readdir(dir)) != NULL) {
if (strncmp(result->d_name, hugepages_dir, sizeof(hugepages_dir)-1)) {
/* not node dir */
}
/* read "hugepages-XXXXXkB" entries */
while ((result = readdir(dir)) != NULL) {
if (strncmp(result->d_name, hugepages_dir, sizeof(hugepages_dir)-1)) {
/* not node dir */
- ssnprintf(path2, sizeof(path2), "%s/%s", path, result->d_name);
+ ssnprintf(path2, (size_t) lim, "%s/%s", path, result->d_name);
- e_info.node = (char *) node;
- walk_directory(path2, read_hugepage_entry, (void *) &e_info, 0);
+ e_info.node = node;
+ walk_directory(path2, read_hugepage_entry, &e_info, 0);
+ errno = 0;
- const char sys_node[] = "/sys/devices/system/node";
- const char node_string[] = "node";
- const char sys_node_hugepages[] = "/sys/devices/system/node/%s/hugepages";
- DIR *dir = NULL;
- struct dirent *result = NULL;
+ static const char sys_node[] = "/sys/devices/system/node";
+ static const char node_string[] = "node";
+ static const char sys_node_hugepages[] = "/sys/devices/system/node/%s/hugepages";
+ DIR *dir;
+ struct dirent *result;
- if (pathconf(sys_node, _PC_NAME_MAX) == -1) {
- /* Limit not defined, or error */
- ERROR("%s: pathconf failed", g_plugin_name);
- closedir(dir);
- return -1;
+ errno = 0;
+ if ((lim = pathconf(sys_node, _PC_NAME_MAX)) == -1) {
+ /* Limit not defined if errno == 0, otherwise error */
+ if (errno != 0) {
+ ERROR("%s: pathconf failed", g_plugin_name);
+ closedir(dir);
+ return -1;
+ } else {
+ lim = PATH_MAX;
+ }
}
while ((result = readdir(dir)) != NULL) {
if (strncmp(result->d_name, node_string, sizeof(node_string)-1)) {
/* not node dir */
}
while ((result = readdir(dir)) != NULL) {
if (strncmp(result->d_name, node_string, sizeof(node_string)-1)) {
/* not node dir */
- ssnprintf(path, sizeof(path), sys_node_hugepages, result->d_name);
+ ssnprintf(path, (size_t) lim, sys_node_hugepages, result->d_name);