summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Styblik <zdenek.styblik@gmail.com>2013-12-17 05:05:43 +0000
committerZdenek Styblik <zdenek.styblik@gmail.com>2013-12-17 05:05:43 +0000
commitd42890ef17c6af792c5475f9b5c48d74a5041440 (patch)
treee23ca5697e128293d24103f29b3e1a6de2e93a2f
parent2d7fe326874a9f151173619b7c714d12cb4d2880 (diff)
downloadipmitool-d42890ef17c6af792c5475f9b5c48d74a5041440.tar.gz
ID: 290 - ipmi_sol.c needs a clean-up
ipmi_sol_payload_access() - change formatting and simplify.
-rw-r--r--ipmitool/lib/ipmi_sol.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/ipmitool/lib/ipmi_sol.c b/ipmitool/lib/ipmi_sol.c
index 1170262..609d458 100644
--- a/ipmitool/lib/ipmi_sol.c
+++ b/ipmitool/lib/ipmi_sol.c
@@ -71,7 +71,7 @@
#define SOL_PARAMETER_SOL_PAYLOAD_CHANNEL 0x07
#define SOL_PARAMETER_SOL_PAYLOAD_PORT 0x08
-#define MAX_SOL_RETRY 6
+#define MAX_SOL_RETRY 6
const struct valstr sol_parameter_vals[] = {
{ SOL_PARAMETER_SET_IN_PROGRESS, "Set In Progress (0)" },
@@ -100,47 +100,45 @@ extern int verbose;
* ipmi_sol_payload_access
*/
int
-ipmi_sol_payload_access(struct ipmi_intf * intf,
- uint8_t channel,
- uint8_t userid,
- int enable)
+ipmi_sol_payload_access(struct ipmi_intf * intf, uint8_t channel,
+ uint8_t userid, int enable)
{
struct ipmi_rq req;
struct ipmi_rs *rsp;
+ int rc = (-1);
uint8_t data[6];
memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = IPMI_SET_USER_PAYLOAD_ACCESS;
- req.msg.data = data;
+ req.msg.netfn = IPMI_NETFN_APP;
+ req.msg.cmd = IPMI_SET_USER_PAYLOAD_ACCESS;
+ req.msg.data = data;
req.msg.data_len = 6;
memset(data, 0, 6);
-
- data[0] = channel & 0xf; /* channel */
- data[1] = userid & 0x3f; /* user id */
- if (!enable)
- data[1] |= 0x40; /* disable */
- data[2] = 0x02; /* payload 1 is SOL */
-
+ /* channel */
+ data[0] = channel & 0xf;
+ /* user id */
+ data[1] = userid & 0x3f;
+ if (!enable) {
+ /* disable */
+ data[1] |= 0x40;
+ }
+ /* payload 1 is SOL */
+ data[2] = 0x02;
rsp = intf->sendrecv(intf, &req);
-
- if (NULL != rsp) {
- switch (rsp->ccode) {
- case 0x00:
- return 0;
- default:
- lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d: %s",
- enable ? "en" : "dis", userid, channel,
- val2str(rsp->ccode, completion_code_vals));
- break;
- }
- } else {
+ if (rsp == NULL) {
lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d",
- enable ? "en" : "dis", userid, channel);
+ enable ? "en" : "dis", userid, channel);
+ rc = (-1);
+ } else if (rsp->ccode != 0) {
+ lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d: %s",
+ enable ? "en" : "dis", userid, channel,
+ val2str(rsp->ccode, completion_code_vals));
+ rc = (-1);
+ } else {
+ rc = 0;
}
-
- return -1;
+ return rc;
}
int