Skip to content

Commit

Permalink
tools: usid: call sid_ifc_rsl_free unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
prajnoha committed Sep 16, 2024
1 parent 3ef22d3 commit 83a80e7
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/tools/usid/usid.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ static int _usid_cmd_active(void)
req.seqnum = sid_util_env_get_ull(KEY_ENV_SEQNUM, 0, UINT64_MAX, &val) < 0 ? 0 : val;
r = sid_ifc_req(&req, &rsl);
ubr_status = _get_ubr_status(rsl, r);
if (r == 0)
sid_ifc_rsl_free(rsl);
fprintf(stdout, KEY_SID_STATUS "=%s\n", sid_status_str[ubr_status]);
sid_ifc_rsl_free(rsl);

fprintf(stdout, KEY_SID_STATUS "=%s\n", sid_status_str[ubr_status]);
return r;
}

Expand Down Expand Up @@ -133,14 +132,14 @@ static int _usid_cmd_print_env(struct sid_ifc_req *req)
req->seqnum = val;
r = sid_ifc_req(req, &rsl);
ubr_status = _get_ubr_status(rsl, r);

if (r < 0) {
if (ubr_status == SID_STATUS_INACTIVE)
/* it's not an error if sid is inactive */
r = 0;
goto out;
}
} else
r = _print_env_from_rsl(rsl);

r = _print_env_from_rsl(rsl);
sid_ifc_rsl_free(rsl);
out:
fprintf(stdout, KEY_SID_STATUS "=%s\n", sid_status_str[ubr_status]);
Expand Down Expand Up @@ -200,25 +199,25 @@ static int _usid_cmd_version(void)

r = sid_ifc_req(&req, &rsl);
ubr_status = _get_ubr_status(rsl, r);

if (r < 0) {
if (ubr_status == SID_STATUS_INACTIVE)
/* it's not an error if sid is inactive */
r = 0;
goto out;
}

if ((data = sid_ifc_rsl_get_data(rsl, NULL)) != NULL) {
fprintf(stdout, "%s", data);
r = 0;
} else {
if (sid_ifc_rsl_get_status(rsl, &status) == 0 && (status & SID_IFC_CMD_STATUS_FAILURE) == 0)
r = -ENODATA;
else
r = -EBADE;
if ((data = sid_ifc_rsl_get_data(rsl, NULL)) != NULL) {
fprintf(stdout, "%s", data);
r = 0;
} else {
if (sid_ifc_rsl_get_status(rsl, &status) == 0 && (status & SID_IFC_CMD_STATUS_FAILURE) == 0)
r = -ENODATA;
else
r = -EBADE;
}
}

sid_ifc_rsl_free(rsl);
out:

fprintf(stdout, KEY_SID_STATUS "=%s\n", sid_status_str[ubr_status]);
if (r < 0)
sid_log_error_errno(LOG_PREFIX, r, "Command request failed");
Expand Down

0 comments on commit 83a80e7

Please sign in to comment.