summaryrefslogtreecommitdiff
path: root/lib/ipmi_channel.c
diff options
context:
space:
mode:
authorAlexander Amelkin <alexander@amelkin.msk.ru>2018-08-15 13:16:37 +0300
committerAlexander Amelkin <alexander@amelkin.msk.ru>2018-08-21 11:55:03 +0300
commit9ecfb762bdc0c87a9e13683e165871475db6a96b (patch)
tree8e2374525030b3c260b825c715452bd4820ef6ed /lib/ipmi_channel.c
parentbb1a4cc80568a5cd3384c2c2303bf3d0f3b9a5dd (diff)
downloadipmitool-9ecfb762bdc0c87a9e13683e165871475db6a96b.tar.gz
Refactoring: get rid of superfluous comparisons
Make code better readable by replacing `if (rsp->ccode > 0)` and 'if (rsp->ccode != 0)' with just `if (rsp->ccode)` as rsp->ccode is anyway an unsigned byte and can't be negative. Also replace 'if (rsp->ccode == 0)' with 'if (!rsp->ccode)'. All these changes make lines shorter and easier to read as a non-zero ccode is an indication of some failure, and so !ccode naturally reads as 'no error'. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Diffstat (limited to 'lib/ipmi_channel.c')
-rw-r--r--lib/ipmi_channel.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/ipmi_channel.c b/lib/ipmi_channel.c
index 16eefe1..74e49bb 100644
--- a/lib/ipmi_channel.c
+++ b/lib/ipmi_channel.c
@@ -89,7 +89,7 @@ _ipmi_get_channel_access(struct ipmi_intf *intf,
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
return (-1);
- } else if (rsp->ccode != 0) {
+ } else if (rsp->ccode) {
return rsp->ccode;
} else if (rsp->data_len != 2) {
return (-2);
@@ -130,7 +130,7 @@ _ipmi_get_channel_info(struct ipmi_intf *intf,
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
return (-1);
- } else if (rsp->ccode != 0) {
+ } else if (rsp->ccode) {
return rsp->ccode;
} else if (rsp->data_len != 9) {
return (-2);
@@ -276,7 +276,7 @@ ipmi_get_channel_auth_cap(struct ipmi_intf *intf, uint8_t channel, uint8_t priv)
rsp = intf->sendrecv(intf, &req);
- if ((rsp == NULL) || (rsp->ccode > 0)) {
+ if (!rsp || rsp->ccode) {
/*
* It's very possible that this failed because we asked for IPMI v2 data
* Ask again, without requesting IPMI v2 data
@@ -288,7 +288,7 @@ ipmi_get_channel_auth_cap(struct ipmi_intf *intf, uint8_t channel, uint8_t priv)
lprintf(LOG_ERR, "Unable to Get Channel Authentication Capabilities");
return (-1);
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Get Channel Authentication Capabilities failed: %s",
val2str(rsp->ccode, completion_code_vals));
return (-1);
@@ -378,7 +378,7 @@ ipmi_get_channel_cipher_suites(struct ipmi_intf *intf, const char *payload_type,
lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -413,7 +413,7 @@ ipmi_get_channel_cipher_suites(struct ipmi_intf *intf, const char *payload_type,
lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -648,8 +648,9 @@ ipmi_get_channel_info(struct ipmi_intf *intf, uint8_t channel)
*
* @channel - IPMI Channel
*
- * returns - IPMI Channel Medium, IPMI_CHANNEL_MEDIUM_RESERVED if ccode > 0,
- * 0 on error.
+ * @returns IPMI Channel Medium
+ * @retval IPMI_CHANNEL_MEDIUM_RESERVED if ccode was not IPMI_CC_OK
+ * @retval 0 on error
*/
uint8_t
ipmi_get_channel_medium(struct ipmi_intf *intf, uint8_t channel)
@@ -663,7 +664,7 @@ ipmi_get_channel_medium(struct ipmi_intf *intf, uint8_t channel)
return IPMI_CHANNEL_MEDIUM_RESERVED;
} else if (ccode < 0 && eval_ccode(ccode) != 0) {
return 0;
- } else if (ccode > 0) {
+ } else if (ccode) {
lprintf(LOG_ERR, "Get Channel Info command failed: %s",
val2str(ccode, completion_code_vals));
return IPMI_CHANNEL_MEDIUM_RESERVED;