diff options
Diffstat (limited to 'lib/ipmi_sunoem.c')
| -rw-r--r-- | lib/ipmi_sunoem.c | 205 | 
1 files changed, 102 insertions, 103 deletions
| diff --git a/lib/ipmi_sunoem.c b/lib/ipmi_sunoem.c index ecbcbd9..d03900d 100644 --- a/lib/ipmi_sunoem.c +++ b/lib/ipmi_sunoem.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 <stdio.h> @@ -197,7 +196,7 @@ static void  __sdr_list_empty(struct sdr_record_list * head)  {  	struct sdr_record_list * e, *f; -	for (e = head; e != NULL; e = f) { +	for (e = head; e; e = f) {  		f = e->next;  		free(e);  	} @@ -254,7 +253,7 @@ sunoem_led_get(struct ipmi_intf * intf,	struct sdr_record_generic_locator * dev,  	uint8_t rqdata[7];  	int rqdata_len; -	if (dev == NULL) { +	if (!dev) {  		*loc_rsp = NULL;  		return (SUNOEM_EC_INVALID_ARG);  	} @@ -283,10 +282,10 @@ sunoem_led_get(struct ipmi_intf * intf,	struct sdr_record_generic_locator * dev,  	 * Just return NULL if there was  	 * an error.  	 */ -	if (rsp == NULL) { +	if (!rsp) {  		*loc_rsp = NULL;  		return (SUNOEM_EC_BMC_NOT_RESPONDING); -	} else if (rsp->ccode > 0) { +	} else if (rsp->ccode) {  		*loc_rsp = rsp;  		return (SUNOEM_EC_BMC_CCODE_NONZERO);  	} else { @@ -304,7 +303,7 @@ sunoem_led_set(struct ipmi_intf * intf, struct sdr_record_generic_locator * dev,  	uint8_t rqdata[9];  	int rqdata_len; -	if (dev == NULL) +	if (!dev)  		return NULL;  	rqdata[0] = dev->dev_slave_addr; @@ -330,10 +329,10 @@ sunoem_led_set(struct ipmi_intf * intf, struct sdr_record_generic_locator * dev,  	req.msg.data_len = rqdata_len;  	rsp = intf->sendrecv(intf, &req); -	if (rsp == NULL) { +	if (!rsp) {  		lprintf(LOG_ERR, "Sun OEM Set LED command failed.");  		return NULL; -	} else if (rsp->ccode > 0) { +	} else if (rsp->ccode) {  		lprintf(LOG_ERR, "Sun OEM Set LED command failed: %s",  				val2str(rsp->ccode, completion_code_vals));  		return NULL; @@ -361,11 +360,11 @@ sunoem_led_get_byentity(struct ipmi_intf * intf, uint8_t entity_id,  	elist = ipmi_sdr_find_sdr_byentity(intf, &entity); -	if (elist == NULL) +	if (!elist)  		ret_get = -1;  	/* for each generic sensor get its led state */ -	for (e = elist; e != NULL; e = e->next) { +	for (e = elist; e; e = e->next) {  		if (e->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR)  			continue; @@ -404,11 +403,11 @@ sunoem_led_set_byentity(struct ipmi_intf * intf, uint8_t entity_id,  	elist = ipmi_sdr_find_sdr_byentity(intf, &entity); -	if (elist == NULL) +	if (!elist)  		ret_set = -1;  	/* for each generic sensor set its led state */ -	for (e = elist; e != NULL; e = e->next) { +	for (e = elist; e; e = e->next) {  		if (e->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR)  			continue; @@ -417,7 +416,7 @@ sunoem_led_set_byentity(struct ipmi_intf * intf, uint8_t entity_id,  		if (rsp && rsp->data_len == 0) {  			led_print((const char *) e->record.genloc->id_string, PRINT_NORMAL,  					ledmode); -		} else if (rsp == NULL) { +		} else if (!rsp) {  			ret_set = -1;  		}  	} @@ -435,14 +434,14 @@ sunoem_led_set_byentity(struct ipmi_intf * intf, uint8_t entity_id,   *                       Access Address" field, 0x20 if the LED is local   * [byte 3]  hwInfo      The OEM field from the SDR record   * [byte 4]  force       1 = directly access the device - *                       0 = go thru its controller + *                       0 = go through its controller   *                       Ignored if LED is local   *   * The format below is for Sun Blade Modular systems only   * [byte 4]  entityID    The entityID field from the SDR record   * [byte 5]  entityIns   The entityIns field from the SDR record   * [byte 6]  force       1 = directly access the device - *                       0 = go thru its controller + *                       0 = go through its controller   *                       Ignored if LED is local   */  static int @@ -460,7 +459,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)  	 * sunoem led/sbled get <id> [type]  	 */ -	if (argc < 1 || strncmp(argv[0], "help", 4) == 0) { +	if (argc < 1 || !strcmp(argv[0], "help")) {  		ipmi_sunoem_usage();  		return (0);  	} @@ -472,15 +471,15 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)  					"Unknown ledtype, will use data from the SDR oem field");  	} -	if (strncasecmp(argv[0], "all", 3) == 0) { +	if (strcasecmp(argv[0], "all") == 0) {  		/* do all generic sensors */  		alist = ipmi_sdr_find_sdr_bytype(intf,  		SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR); -		if (alist == NULL) +		if (!alist)  			return (-1); -		for (a = alist; a != NULL; a = a->next) { +		for (a = alist; a; a = a->next) {  			if (a->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR)  				continue;  			if (a->record.genloc->entity.logical) @@ -511,7 +510,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)  	/* look up generic device locator record in SDR */  	sdr = ipmi_sdr_find_sdr_byid(intf, argv[0]); -	if (sdr == NULL) { +	if (!sdr) {  		lprintf(LOG_ERR, "No Sensor Data Record found for %s", argv[0]);  		return (-1);  	} @@ -556,14 +555,14 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)  	/* get entity assoc records */  	alist = ipmi_sdr_find_sdr_bytype(intf, SDR_RECORD_TYPE_ENTITY_ASSOC); -	if (alist == NULL) +	if (!alist)  		return (-1); -	for (a = alist; a != NULL; a = a->next) { +	for (a = alist; a; a = a->next) {  		if (a->type != SDR_RECORD_TYPE_ENTITY_ASSOC)  			continue;  		assoc = a->record.entassoc; -		if (assoc == NULL) +		if (!assoc)  			continue;  		/* check that the entity id/instance matches our generic record */ @@ -625,7 +624,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)   * [byte 3]  hwInfo      The OEM field from the SDR record   * [byte 4]  mode        LED Mode: OFF, ON, STANDBY, SLOW, FAST   * [byte 5]  force       TRUE - directly access the device - *                       FALSE - go thru its controller + *                       FALSE - go through its controller   *                       Ignored if LED is local   * [byte 6]  role        Used by BMC for authorization purposes   * @@ -633,7 +632,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)   * [byte 5]  entityID    The entityID field from the SDR record   * [byte 6]  entityIns   The entityIns field from the SDR record   * [byte 7]  force       TRUE - directly access the device - *                       FALSE - go thru its controller + *                       FALSE - go through its controller   *                       Ignored if LED is local   * [byte 8]  role        Used by BMC for authorization purposes   * @@ -658,7 +657,7 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)  	 * sunoem led/sbled set <id> <mode> [type]  	 */ -	if (argc < 2 || strncmp(argv[0], "help", 4) == 0) { +	if (argc < 2 || !strcmp(argv[0], "help")) {  		ipmi_sunoem_usage();  		return (0);  	} @@ -679,21 +678,21 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)  					"Unknown ledtype, will use data from the SDR oem field");  	} -	if (strncasecmp(argv[0], "all", 3) == 0) { +	if (strcasecmp(argv[0], "all") == 0) {  		/* do all generic sensors */  		alist = ipmi_sdr_find_sdr_bytype(intf,  		SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR); -		if (alist == NULL) +		if (!alist)  			return (-1); -		for (a = alist; a != NULL; a = a->next) { +		for (a = alist; a; a = a->next) {  			if (a->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR)  				continue;  			if (a->record.genloc->entity.logical)  				continue;  			rsp = sunoem_led_set(intf, a->record.genloc, ledtype, ledmode); -			if (rsp && rsp->ccode == 0) +			if (rsp && !rsp->ccode)  				led_print((const char *) a->record.genloc->id_string,  						PRINT_NORMAL, ledmode);  			else @@ -710,7 +709,7 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)  	/* look up generic device locator records in SDR */  	sdr = ipmi_sdr_find_sdr_byid(intf, argv[0]); -	if (sdr == NULL) { +	if (!sdr) {  		lprintf(LOG_ERR, "No Sensor Data Record found for %s", argv[0]);  		return (-1);  	} @@ -725,7 +724,7 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)  		 * handle physical entity  		 */  		rsp = sunoem_led_set(intf, sdr->record.genloc, ledtype, ledmode); -		if (rsp && rsp->ccode == 0) +		if (rsp && !rsp->ccode)  			led_print(argv[0], PRINT_NORMAL, ledmode);  		else  			return (-1); @@ -742,14 +741,14 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)  	/* get entity assoc records */  	alist = ipmi_sdr_find_sdr_bytype(intf, SDR_RECORD_TYPE_ENTITY_ASSOC); -	if (alist == NULL) +	if (!alist)  		return (-1); -	for (a = alist; a != NULL; a = a->next) { +	for (a = alist; a; a = a->next) {  		if (a->type != SDR_RECORD_TYPE_ENTITY_ASSOC)  			continue;  		assoc = a->record.entassoc; -		if (assoc == NULL) +		if (!assoc)  			continue;  		/* check that the entity id/instance matches our generic record */ @@ -813,10 +812,10 @@ ipmi_sunoem_sshkey_del(struct ipmi_intf * intf, uint8_t uid)  	req.msg.data_len = 1;  	rsp = intf->sendrecv(intf, &req); -	if (rsp == NULL) { +	if (!rsp) {  		lprintf(LOG_ERR, "Unable to delete ssh key for UID %d", uid);  		return (-1); -	} else if (rsp->ccode > 0) { +	} else if (rsp->ccode) {  		lprintf(LOG_ERR, "Unable to delete ssh key for UID %d: %s", uid,  				val2str(rsp->ccode, completion_code_vals));  		return (-1); @@ -839,13 +838,13 @@ ipmi_sunoem_sshkey_set(struct ipmi_intf * intf, uint8_t uid, char * ifile)  	int32_t r = 0;  	int32_t size = 0; -	if (ifile == NULL) { +	if (!ifile) {  		lprintf(LOG_ERR, "Invalid or misisng input filename.");  		return (-1);  	}  	fp = ipmi_open_file_read(ifile); -	if (fp == NULL) { +	if (!fp) {  		lprintf(LOG_ERR, "Unable to open file '%s' for reading.", ifile);  		return (-1);  	} @@ -857,7 +856,7 @@ ipmi_sunoem_sshkey_set(struct ipmi_intf * intf, uint8_t uid, char * ifile)  	if (fseek(fp, 0, SEEK_END) == (-1)) {  		lprintf(LOG_ERR, "Failed to seek in file '%s'.", ifile); -		if (fp != NULL) +		if (fp)  			fclose(fp);  		return (-1); @@ -866,13 +865,13 @@ ipmi_sunoem_sshkey_set(struct ipmi_intf * intf, uint8_t uid, char * ifile)  	size = (int32_t) ftell(fp);  	if (size < 0) {  		lprintf(LOG_ERR, "Failed to seek in file '%s'.", ifile); -		if (fp != NULL) +		if (fp)  			fclose(fp);  		return (-1);  	} else if (size == 0) {  		lprintf(LOG_ERR, "File '%s' is empty.", ifile); -		if (fp != NULL) +		if (fp)  			fclose(fp);  		return (-1); @@ -880,7 +879,7 @@ ipmi_sunoem_sshkey_set(struct ipmi_intf * intf, uint8_t uid, char * ifile)  	if (fseek(fp, 0, SEEK_SET) == (-1)) {  		lprintf(LOG_ERR, "Failed to seek in file '%s'.", ifile); -		if (fp != NULL) +		if (fp)  			fclose(fp);  		return (-1); @@ -900,7 +899,7 @@ ipmi_sunoem_sshkey_set(struct ipmi_intf * intf, uint8_t uid, char * ifile)  			printf("failed\n");  			lprintf(LOG_ERR, "Unable to read %ld bytes from file '%s'.", i_size,  					ifile); -			if (fp != NULL) +			if (fp)  				fclose(fp);  			return (-1); @@ -917,7 +916,7 @@ ipmi_sunoem_sshkey_set(struct ipmi_intf * intf, uint8_t uid, char * ifile)  				printf("failed\n");  				lprintf(LOG_ERR, "Unable to pack byte %ld from file '%s'.", r,  						ifile); -				if (fp != NULL) +				if (fp)  					fclose(fp);  				return (-1); @@ -930,23 +929,23 @@ ipmi_sunoem_sshkey_set(struct ipmi_intf * intf, uint8_t uid, char * ifile)  		req.msg.data_len = i_size + 3;  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			printf("failed\n");  			lprintf(LOG_ERR, "Unable to set ssh key for UID %d.", uid); -			if (fp != NULL) +			if (fp)  				fclose(fp);  			return (-1); -		} /* if (rsp == NULL) */ -		if (rsp->ccode != 0) { +		} +		if (rsp->ccode) {  			printf("failed\n");  			lprintf(LOG_ERR, "Unable to set ssh key for UID %d, %s.", uid,  					val2str(rsp->ccode, completion_code_vals)); -			if (fp != NULL) +			if (fp)  				fclose(fp);  			return (-1); -		} /* if (rsp->ccode != 0) */ +		}  	}  	printf("done\n"); @@ -1077,7 +1076,7 @@ ipmi_sunoem_cli(struct ipmi_intf * intf, int argc, char *argv[])  	memset(&cli_req, 0, sizeof(cli_req));  	cli_req.version = SunOemCliActingVersion;  	cli_req.command_response = SUNOEM_CLI_CMD_OPEN; -	if (argc > 0 && strcmp(argv[0], "force") == 0) { +	if (argc > 0 && !strcmp(argv[0], "force")) {  		cli_req.command_response = SUNOEM_CLI_CMD_FORCE;  		argc--;  		argv++; @@ -1091,16 +1090,15 @@ ipmi_sunoem_cli(struct ipmi_intf * intf, int argc, char *argv[])  	while (1) {  		cli_req.version = SunOemCliActingVersion;  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			lprintf(LOG_ERR, "Sun OEM cli command failed");  			return (-1);  		}  		cli_rsp = (sunoem_cli_msg_t *) rsp->data; -		if ((cli_rsp->command_response != 0) || (rsp->ccode != 0)) { -			if (strncmp(cli_rsp->buf, SUNOEM_CLI_INVALID_VER_ERR, -					sizeof(SUNOEM_CLI_INVALID_VER_ERR) - 1) == 0 -					|| strncmp(&(cli_rsp->buf[1]), SUNOEM_CLI_INVALID_VER_ERR, -							sizeof(SUNOEM_CLI_INVALID_VER_ERR) - 1) == 0) { +		if (cli_rsp->command_response || rsp->ccode) { +			if (!strcmp(cli_rsp->buf, SUNOEM_CLI_INVALID_VER_ERR) +			    || !strcmp(&(cli_rsp->buf[1]), SUNOEM_CLI_INVALID_VER_ERR)) +			{  				if (SunOemCliActingVersion == SUNOEM_CLI_VERSION) {  					/* Server doesn't support version SUNOEM_CLI_VERSION  					 Fall back to legacy version, and try again*/ @@ -1110,8 +1108,7 @@ ipmi_sunoem_cli(struct ipmi_intf * intf, int argc, char *argv[])  				/* Server doesn't support legacy version either */  				lprintf(LOG_ERR, "Failed to connect: %s", cli_rsp->buf);  				return (-1); -			} else if (strncmp(cli_rsp->buf, SUNOEM_CLI_BUSY_ERR, -					sizeof(SUNOEM_CLI_BUSY_ERR) - 1) == 0) { +			} else if (!strcmp(cli_rsp->buf, SUNOEM_CLI_BUSY_ERR)) {  				if (retries++ < SUNOEM_CLI_MAX_RETRY) {  					lprintf(LOG_INFO, "Failed to connect: %s, retrying",  							cli_rsp->buf); @@ -1155,7 +1152,7 @@ ipmi_sunoem_cli(struct ipmi_intf * intf, int argc, char *argv[])  			return (-1);  		}  	} -	while (rsp->ccode == 0 && cli_rsp->command_response == 0) { +	while (!rsp->ccode && cli_rsp->command_response == 0) {  		int rc = 0;  		int count = 0;  		cli_req.buf[0] = '\0'; @@ -1197,7 +1194,7 @@ ipmi_sunoem_cli(struct ipmi_intf * intf, int argc, char *argv[])  			} else if (arg_num >= argc) {  				/* Last arg was sent. Set EOF */  				cli_req.command_response = SUNOEM_CLI_CMD_EOF; -			} else if (strncmp(argv[arg_num], "@wait=", 6) == 0) { +			} else if (!strcmp(argv[arg_num], "@wait=")) {  				/* This is a wait command */  				char *s = &argv[arg_num][6];  				delay = 0; @@ -1254,7 +1251,7 @@ ipmi_sunoem_cli(struct ipmi_intf * intf, int argc, char *argv[])  			req.msg.data_len = SUNOEM_CLI_HEADER + count;  			for (retries = 0; retries <= SUNOEM_CLI_MAX_RETRY; retries++) {  				rsp = intf->sendrecv(intf, &req); -				if (rsp == NULL) { +				if (!rsp) {  					lprintf(LOG_ERR, "Communication error.");  					error = 1;  					goto cleanup; @@ -1281,7 +1278,7 @@ ipmi_sunoem_cli(struct ipmi_intf * intf, int argc, char *argv[])  			fflush(NULL); /* Flush partial lines to stdout */  			count = 0; /* Don't re-send the client's data */  			if (cli_req.command_response == SUNOEM_CLI_CMD_EOF -					&& cli_rsp->command_response != 0 && rsp->ccode == 0) { +					&& cli_rsp->command_response != 0 && !rsp->ccode) {  				cli_rsp->command_response = 1;  			}  		} while (cli_rsp->command_response == 0 && cli_rsp->buf[0] != '\0'); @@ -1381,7 +1378,7 @@ ipmi_sunoem_echo(struct ipmi_intf * intf, int argc, char *argv[])  		gettimeofday(&end_time, NULL);  		resp_time = ((end_time.tv_sec - start_time.tv_sec) * 1000)  				+ ((end_time.tv_usec - start_time.tv_usec) / 1000); -		if ((rsp == NULL) || (rsp->ccode != 0)) { +		if (!rsp || rsp->ccode) {  			lprintf(LOG_ERR, "Sun OEM echo command failed. Seq # %d",  					echo_req.seq_num);  			rc = (-2); @@ -1466,7 +1463,7 @@ typedef struct  	/*  	 * When adding new fields (using the spare bytes),  	 * add it immediately after the spare field to -	 * ensure backward compatability. +	 * ensure backward compatibility.  	 *  	 * e.g.   char version[40];  	 *        unsigned char spare[11]; @@ -1501,11 +1498,11 @@ ipmi_sunoem_getversion(struct ipmi_intf * intf,  	req.msg.data_len = 0;  	rsp = intf->sendrecv(intf, &req); -	if (rsp == NULL) { +	if (!rsp) {  		lprintf(LOG_ERR, "Sun OEM Get SP Version Failed.");  		return (-1);  	} -	if (rsp->ccode != 0) { +	if (rsp->ccode) {  		lprintf(LOG_ERR, "Sun OEM Get SP Version Failed: %d", rsp->ccode);  		return (-1);  	} @@ -1651,11 +1648,11 @@ ipmi_sunoem_nacname(struct ipmi_intf * intf, int argc, char *argv[])  		req.msg.data_len = sizeof(sunoem_nacname_t);  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			lprintf(LOG_ERR, "Sun OEM nacname command failed.");  			return (-1);  		} -		if (rsp->ccode != 0) { +		if (rsp->ccode) {  			lprintf(LOG_ERR, "Sun OEM nacname command failed: %d", rsp->ccode);  			return (-1);  		} @@ -1800,7 +1797,7 @@ ipmi_sunoem_getval(struct ipmi_intf * intf, int argc, char *argv[])  	}  	if ((ipmi_sunoem_checkversion(intf, &supp_ver) < 0) -			&& (!strncmp(argv[0], sp_path, strlen(sp_path)))) { +			&& (!strcmp(argv[0], sp_path))) {  		argv[0][1] = 'X'; /*replace SP by X to gain access to hidden properties*/  		memmove(&argv[0][2], &argv[0][3], strlen(argv[0]) - 2);  	} @@ -1821,11 +1818,11 @@ ipmi_sunoem_getval(struct ipmi_intf * intf, int argc, char *argv[])  	req.msg.data_len = sizeof(sunoem_getval_t);  	rsp = intf->sendrecv(intf, &req); -	if (rsp == NULL) { +	if (!rsp) {  		lprintf(LOG_ERR, "Sun OEM getval1 command failed.");  		return (-1);  	} -	if (rsp->ccode != 0) { +	if (rsp->ccode) {  		lprintf(LOG_ERR, "Sun OEM getval1 command failed: %d", rsp->ccode);  		return (-1);  	} @@ -1843,12 +1840,12 @@ ipmi_sunoem_getval(struct ipmi_intf * intf, int argc, char *argv[])  		req.msg.data_len = sizeof(sunoem_getval_t);  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			lprintf(LOG_ERR, "Sun OEM getval2 command failed.");  			return (-1);  		} -		if (rsp->ccode != 0) { +		if (rsp->ccode) {  			lprintf(LOG_ERR, "Sun OEM getval2 command failed: %d", rsp->ccode);  			return (-1);  		} @@ -1911,12 +1908,12 @@ send_luapi_prop_name(struct ipmi_intf * intf, int len, char *prop_name,  		req.msg.data_len = sizeof(sunoem_setval_t);  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			lprintf(LOG_ERR, "Sun OEM setval prop name: response is NULL");  			return (-1);  		} -		if (rsp->ccode != 0) { +		if (rsp->ccode) {  			lprintf(LOG_ERR, "Sun OEM setval prop name: request failed: %d",  					rsp->ccode);  			return (-1); @@ -1984,12 +1981,12 @@ send_luapi_prop_value(struct ipmi_intf * intf, int len,	char *prop_value,  		req.msg.data_len = sizeof(sunoem_setval_t);  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			lprintf(LOG_ERR, "Sun OEM setval prop value: response is NULL");  			return (-1);  		} -		if (rsp->ccode != 0) { +		if (rsp->ccode) {  			lprintf(LOG_ERR, "Sun OEM setval prop value: request failed: %d",  					rsp->ccode);  			return (-1); @@ -2077,12 +2074,12 @@ ipmi_sunoem_setval(struct ipmi_intf * intf, int argc, char *argv[])  		req.msg.data_len = sizeof(sunoem_setval_t);  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			lprintf(LOG_ERR, "Sun OEM setval command failed.");  			return (-1);  		} -		if (rsp->ccode != 0) { +		if (rsp->ccode) {  			lprintf(LOG_ERR, "Sun OEM setval command failed: %d", rsp->ccode);  			return (-1);  		} @@ -2167,7 +2164,7 @@ ipmi_sunoem_getfile(struct ipmi_intf * intf, int argc, char *argv[])  	/* Create the destination file */  	fp = ipmi_open_file_write(argv[1]); -	if (fp == NULL) { +	if (!fp) {  		lprintf(LOG_ERR, "Unable to open file: %s", argv[1]);  		return (-1);  	} @@ -2188,12 +2185,12 @@ ipmi_sunoem_getfile(struct ipmi_intf * intf, int argc, char *argv[])  		rsp = intf->sendrecv(intf, &req); -		if (rsp == NULL) { +		if (!rsp) {  			lprintf(LOG_ERR, "Sun OEM getfile command failed.");  			fclose(fp);  			return (-1);  		} -		if (rsp->ccode != 0) { +		if (rsp->ccode) {  			lprintf(LOG_ERR, "Sun OEM getfile command failed: %d", rsp->ccode);  			fclose(fp);  			return (-1); @@ -2301,12 +2298,12 @@ ipmi_sunoem_getbehavior(struct ipmi_intf * intf, int argc, char *argv[])  	rsp = intf->sendrecv(intf, &req); -	if (rsp == NULL) { +	if (!rsp) {  		lprintf(LOG_ERR, "Sun OEM getbehavior command failed.");  		return (-1);  	} -	if (rsp->ccode != 0) { +	if (rsp->ccode) {  		lprintf(LOG_ERR, "Sun OEM getbehavior command failed: %d", rsp->ccode);  		return (-1);  	} @@ -2323,27 +2320,29 @@ ipmi_sunoem_main(struct ipmi_intf * intf, int argc, char ** argv)  {  	int rc = 0; -	if (argc == 0 || strcmp(argv[0], "help") == 0) { +	if (!argc || !strcmp(argv[0], "help")) {  		ipmi_sunoem_usage();  		return (0); -	} /* if (argc == 0 || strcmp(argv[0], "help") == 0) */ +	} -	if (strcmp(argv[0], "cli") == 0) { +	if (!strcmp(argv[0], "cli")) {  		rc = ipmi_sunoem_cli(intf, argc - 1, &argv[1]); -	} else if ((strcmp(argv[0], "led") == 0) || (strcmp(argv[0], "sbled") == 0)) { +	} else if (!strcmp(argv[0], "led") +	           || !strcmp(argv[0], "sbled")) +	{  		if (argc < 2) {  			ipmi_sunoem_usage();  			return (-1);  		} -		if (strcmp(argv[1], "get") == 0) { +		if (!strcmp(argv[1], "get")) {  			if (argc < 3) {  				char * arg[] = { "all" };  				rc = ipmi_sunoem_led_get(intf, 1, arg);  			} else {  				rc = ipmi_sunoem_led_get(intf, argc - 2, &(argv[2]));  			} -		} else if (strcmp(argv[1], "set") == 0) { +		} else if (!strcmp(argv[1], "set")) {  			if (argc < 4) {  				ipmi_sunoem_usage();  				return (-1); @@ -2353,7 +2352,7 @@ ipmi_sunoem_main(struct ipmi_intf * intf, int argc, char ** argv)  			ipmi_sunoem_usage();  			return (-1);  		} -	} else if (strcmp(argv[0], "sshkey") == 0) { +	} else if (!strcmp(argv[0], "sshkey")) {  		uint8_t uid = 0;  		if (argc < 3) {  			ipmi_sunoem_usage(); @@ -2371,10 +2370,10 @@ ipmi_sunoem_main(struct ipmi_intf * intf, int argc, char ** argv)  			return (-1);  		} -		if (strcmp(argv[1], "del") == 0) { +		if (!strcmp(argv[1], "del")) {  			/* number of arguments, three, is already checked at this point */  			rc = ipmi_sunoem_sshkey_del(intf, uid); -		} else if (strcmp(argv[1], "set") == 0) { +		} else if (!strcmp(argv[1], "set")) {  			if (argc < 4) {  				ipmi_sunoem_usage();  				return (-1); @@ -2384,39 +2383,39 @@ ipmi_sunoem_main(struct ipmi_intf * intf, int argc, char ** argv)  			ipmi_sunoem_usage();  			return (-1);  		} -	} else if (strcmp(argv[0], "ping") == 0) { +	} else if (!strcmp(argv[0], "ping")) {  		if (argc < 2) {  			ipmi_sunoem_usage();  			return (-1);  		}  		rc = ipmi_sunoem_echo(intf, argc - 1, &(argv[1])); -	} else if (strcmp(argv[0], "version") == 0) { +	} else if (!strcmp(argv[0], "version")) {  		rc = ipmi_sunoem_version(intf); -	} else if (strcmp(argv[0], "nacname") == 0) { +	} else if (!strcmp(argv[0], "nacname")) {  		if (argc < 2) {  			ipmi_sunoem_usage();  			return (-1);  		}  		rc = ipmi_sunoem_nacname(intf, argc - 1, &(argv[1])); -	} else if (strcmp(argv[0], "getval") == 0) { +	} else if (!strcmp(argv[0], "getval")) {  		if (argc < 2) {  			ipmi_sunoem_usage();  			return (-1);  		}  		rc = ipmi_sunoem_getval(intf, argc - 1, &(argv[1])); -	} else if (strcmp(argv[0], "setval") == 0) { +	} else if (!strcmp(argv[0], "setval")) {  		if (argc < 3) {  			ipmi_sunoem_usage();  			return (-1);  		}  		rc = ipmi_sunoem_setval(intf, argc - 1, &(argv[1])); -	} else if (strcmp(argv[0], "getfile") == 0) { +	} else if (!strcmp(argv[0], "getfile")) {  		if (argc < 3) {  			ipmi_sunoem_usage();  			return (-1);  		}  		rc = ipmi_sunoem_getfile(intf, argc - 1, &(argv[1])); -	} else if (strcmp(argv[0], "getbehavior") == 0) { +	} else if (!strcmp(argv[0], "getbehavior")) {  		if (argc < 2) {  			ipmi_sunoem_usage();  			return (-1); @@ -2425,7 +2424,7 @@ ipmi_sunoem_main(struct ipmi_intf * intf, int argc, char ** argv)  	} else {  		lprintf(LOG_ERR, "Invalid sunoem command: %s", argv[0]);  		return (-1); -	} /* if (strcmp(argv[0], "cli") == 0) */ +	}  	return (rc);  } | 
