summaryrefslogtreecommitdiff
path: root/lib/ipmi_isol.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipmi_isol.c')
-rw-r--r--lib/ipmi_isol.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/lib/ipmi_isol.c b/lib/ipmi_isol.c
index bc0b08b..1c2708f 100644
--- a/lib/ipmi_isol.c
+++ b/lib/ipmi_isol.c
@@ -29,7 +29,6 @@
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-#define _XOPEN_SOURCE
#include <stdlib.h>
#include <string.h>
@@ -84,7 +83,7 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1;
}
@@ -92,7 +91,7 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
lprintf(LOG_ERR, "IPMI v1.5 Serial Over Lan (ISOL) not supported!");
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -108,11 +107,11 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -128,11 +127,11 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -193,12 +192,12 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/*
* enabled
*/
- if (strcmp(param, "enabled") == 0)
+ if (!strcmp(param, "enabled"))
{
data[1] = ISOL_ENABLE_PARAM;
- if (strcmp(value, "true") == 0)
+ if (!strcmp(value, "true"))
data[2] = 0x01;
- else if (strcmp(value, "false") == 0)
+ else if (!strcmp(value, "false"))
data[2] = 0x00;
else {
lprintf(LOG_ERR, "Invalid value %s for parameter %s",
@@ -211,7 +210,7 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/*
* privilege-level
*/
- else if (strcmp(param, "privilege-level") == 0)
+ else if (!strcmp(param, "privilege-level"))
{
data[1] = ISOL_AUTHENTICATION_PARAM;
if (! strcmp(value, "user"))
@@ -236,22 +235,22 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/*
* bit-rate
*/
- else if (strcmp(param, "bit-rate") == 0)
+ else if (!strcmp(param, "bit-rate"))
{
data[1] = ISOL_BAUD_RATE_PARAM;
- if (strncmp(value, "9.6", 3) == 0) {
+ if (!strcmp(value, "9.6")) {
data[2] = 0x06;
}
- else if (strncmp(value, "19.2", 4) == 0) {
+ else if (!strcmp(value, "19.2")) {
data[2] = 0x07;
}
- else if (strncmp(value, "38.4", 4) == 0) {
+ else if (!strcmp(value, "38.4")) {
data[2] = 0x08;
}
- else if (strncmp(value, "57.6", 4) == 0) {
+ else if (!strcmp(value, "57.6")) {
data[2] = 0x09;
}
- else if (strncmp(value, "115.2", 5) == 0) {
+ else if (!strcmp(value, "115.2")) {
data[2] = 0x0A;
}
else {
@@ -272,11 +271,11 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
*/
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error setting ISOL parameter '%s'", param);
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Error setting ISOL parameter '%s': %s",
param, val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -429,11 +428,11 @@ ipmi_isol_deactivate(struct ipmi_intf * intf)
data[5] = 0x00;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error deactivating ISOL");
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Error deactivating ISOL: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@@ -573,7 +572,7 @@ ipmi_isol_red_pill(struct ipmi_intf * intf)
int timedout = 0;
buffer = (char*)malloc(buffer_size);
- if (buffer == NULL) {
+ if (!buffer) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1;
}
@@ -791,20 +790,20 @@ int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
/*
* Help
*/
- if (!argc || !strncmp(argv[0], "help", 4))
+ if (!argc || !strcmp(argv[0], "help"))
print_isol_usage();
/*
* Info
*/
- else if (!strncmp(argv[0], "info", 4)) {
+ else if (!strcmp(argv[0], "info")) {
ret = ipmi_print_isol_info(intf);
}
/*
* Set a parameter value
*/
- else if (!strncmp(argv[0], "set", 3)) {
+ else if (!strcmp(argv[0], "set")) {
if (argc < 3) {
print_isol_set_usage();
return -1;
@@ -815,7 +814,7 @@ int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
/*
* Activate
*/
- else if (!strncmp(argv[0], "activate", 8)) {
+ else if (!strcmp(argv[0], "activate")) {
ret = ipmi_isol_activate(intf);
}