*
* LGPL HEADER END
*
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2014, Intel Corporation.
*
* Author:
* Amir Shehata <amir.shehata@intel.com>
struct cYAML *root = NULL, *route = NULL, *item = NULL;
struct cYAML *first_seq = NULL;
char err_str[LNET_MAX_STR_LEN];
+ bool exist = false;
snprintf(err_str, sizeof(err_str),
"\"out of memory\"");
/* default rc to -1 incase we hit the goto */
rc = -1;
+ exist = true;
item = cYAML_create_seq_item(route);
if (item == NULL)
snprintf(err_str, sizeof(err_str), "\"success\"");
out:
- if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR) {
+ if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR || !exist) {
cYAML_free_tree(root);
} else if (show_rc != NULL && *show_rc != NULL) {
struct cYAML *show_node;
char str_buf[str_buf_len];
char *pos;
char err_str[LNET_MAX_STR_LEN];
+ bool exist = false;
snprintf(err_str, sizeof(err_str), "\"out of memory\"");
/* default rc to -1 in case we hit the goto */
rc = -1;
+ exist = true;
net_config = (struct lnet_ioctl_net_config *)data->cfg_bulk;
snprintf(err_str, sizeof(err_str), "\"success\"");
out:
- if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR) {
+ if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR || !exist) {
cYAML_free_tree(root);
} else if (show_rc != NULL && *show_rc != NULL) {
struct cYAML *show_node;
struct cYAML *root = NULL, *pools_node = NULL,
*type_node = NULL, *item = NULL, *cpt = NULL,
*first_seq = NULL;
- int i;
+ int i, j;
char err_str[LNET_MAX_STR_LEN];
char node_name[LNET_MAX_STR_LEN];
+ bool exist = false;
snprintf(err_str, sizeof(err_str), "\"out of memory\"");
if (rc != 0)
break;
+ exist = true;
+
pool_cfg = (struct lnet_ioctl_pool_cfg *)data->cfg_bulk;
snprintf(node_name, sizeof(node_name), "cpt[%d]", i);
goto out;
/* create the tree and print */
- for (i = 0; i < LNET_NRBPOOLS; i++) {
- type_node = cYAML_create_object(cpt, pools[i]);
+ for (j = 0; j < LNET_NRBPOOLS; j++) {
+ type_node = cYAML_create_object(cpt, pools[j]);
if (type_node == NULL)
goto out;
if (cYAML_create_number(type_node, "npages",
- pool_cfg->pl_pools[i].pl_npages)
+ pool_cfg->pl_pools[j].pl_npages)
== NULL)
goto out;
if (cYAML_create_number(type_node, "nbuffers",
- pool_cfg->pl_pools[i].
+ pool_cfg->pl_pools[j].
pl_nbuffers) == NULL)
goto out;
if (cYAML_create_number(type_node, "credits",
- pool_cfg->pl_pools[i].
+ pool_cfg->pl_pools[j].
pl_credits) == NULL)
goto out;
if (cYAML_create_number(type_node, "mincredits",
- pool_cfg->pl_pools[i].
+ pool_cfg->pl_pools[j].
pl_mincredits) == NULL)
goto out;
}
out:
free(buf);
- if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR) {
+ if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR || !exist) {
cYAML_free_tree(root);
} else if (show_rc != NULL && *show_rc != NULL) {
struct cYAML *show_node;
while ((head = cYAML_get_next_seq_item(child, &item))
!= NULL) {
rc = cb(head, show_rc, err_rc);
- /* if processing fails or no cb is found
- * then fail */
- if (rc != LUSTRE_CFG_RC_NO_ERR) {
- snprintf(err_str, sizeof(err_str),
- "\"Failed to process request: "
- "'%s' [%d, %p]\"",
- head->cy_string, rc, cb);
- cYAML_build_error(
- LUSTRE_CFG_RC_BAD_PARAM, -1,
- "yaml", "helper", err_str,
- err_rc);
+ if (rc != LUSTRE_CFG_RC_NO_ERR)
return_rc = rc;
- }
}
} else {
rc = cb(child, show_rc, err_rc);
- /* if processing fails or no cb is found then fail */
- if (rc != LUSTRE_CFG_RC_NO_ERR) {
- snprintf(err_str, sizeof(err_str),
- "\"Failed to process request: '%s'"
- " [%d, %p]\"",
- child->cy_string, rc, cb);
- cYAML_build_error(LUSTRE_CFG_RC_BAD_PARAM, -1,
- "yaml", "helper", err_str, err_rc);
+ if (rc != LUSTRE_CFG_RC_NO_ERR)
return_rc = rc;
- }
}
item = NULL;
child = child->cy_next;