X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fliblustreapi_param.c;h=49b07733200f862f18c5e8fbc47622ec44725808;hb=69eb7b89c7f36ec6a8970e87fc8859207f4b9c0c;hp=a1f52ca5a4e951713da89873b2a0766796af0c38;hpb=ba0d5ffc1c0eaa0ac0b59cacc992928e80a15bf2;p=fs%2Flustre-release.git diff --git a/lustre/utils/liblustreapi_param.c b/lustre/utils/liblustreapi_param.c index a1f52ca..49b0773 100644 --- a/lustre/utils/liblustreapi_param.c +++ b/lustre/utils/liblustreapi_param.c @@ -202,10 +202,14 @@ int llapi_param_get_paths(const char *pattern, glob_t *paths) */ static int bytes_remaining(int fd, size_t *file_size) { - int rc = 0; size_t bytes_read = 0; - long page_size = sysconf(_SC_PAGESIZE); + long page_size; char *temp_buf; + int rc = 0; + + page_size = sysconf(_SC_PAGESIZE); + if (page_size < 0) + return -EINVAL; temp_buf = malloc(page_size); if (temp_buf == NULL) @@ -252,12 +256,17 @@ static int required_size(const char *path, size_t *file_size) static int copy_file_expandable(const char *path, char **buf, size_t *file_size) { - long page_size = sysconf(_SC_PAGESIZE); - int rc = 0; + long page_size; char *temp_buf; - int fd; + int rc = 0, fd; FILE *fp; + page_size = sysconf(_SC_PAGESIZE); + if (page_size < 0) { + rc = -errno; + goto out; + } + fp = open_memstream(buf, file_size); if (fp == NULL) { rc = -errno; @@ -449,6 +458,7 @@ static int print_out_devices(yaml_parser_t *reply, enum lctl_param_flags flags) } bzero(buf, sizeof(buf)); tmp = buf; + buf_len = sizeof(buf); } if (event.type == YAML_SCALAR_EVENT) { @@ -504,8 +514,8 @@ static int print_out_devices(yaml_parser_t *reply, enum lctl_param_flags flags) return rc; } -int lcfg_param_get_yaml(yaml_parser_t *reply, struct nl_sock *sk, - int version, char *pattern) +static int lcfg_param_get_yaml(yaml_parser_t *reply, struct nl_sock *sk, + int version, char *pattern) { char source[PATH_MAX / 2], group[GENL_NAMSIZ + 1]; char *family = "lustre", *tmp;