struct dirent *result;
char path2[PATH_MAX];
struct entry_info e_info;
- long lim;
dir = opendir(path);
if (dir == NULL) {
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)) {
}
/* /sys/devices/system/node/node?/hugepages/ */
- ssnprintf(path2, (size_t)lim, "%s/%s", path, result->d_name);
+ ssnprintf(path2, sizeof(path2), "%s/%s", path, result->d_name);
e_info.d_name = result->d_name;
e_info.node = node;
DIR *dir;
struct dirent *result;
char path[PATH_MAX];
- long lim;
dir = opendir(sys_node);
if (dir == NULL) {
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 */
continue;
}
- ssnprintf(path, (size_t)lim, sys_node_hugepages, result->d_name);
+ ssnprintf(path, sizeof(path), sys_node_hugepages, result->d_name);
read_syshugepages(path, result->d_name);
errno = 0;
}