Refactoring: optimize pointer checks

Remove all direct comparisons to 'NULL' for pointers.
Replace them with boolean-like 'if (ptr)' and 'if (!ptr)'.
This makes conditions shorter and easier to read.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin
2018-08-21 17:16:19 +03:00
parent f3ef88724f
commit e9716e216d
48 changed files with 1050 additions and 1090 deletions

View File

@@ -103,7 +103,7 @@ ipmi_tsol_command(struct ipmi_intf *intf, char *recvip, int port,
data[5] = (port & 0xff);
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
if (!rsp) {
lprintf(LOG_ERR, "Unable to perform TSOL command");
return (-1);
}
@@ -148,7 +148,7 @@ ipmi_tsol_send_keystroke(struct ipmi_intf *intf, char *buff, int length)
rsp = intf->sendrecv(intf, &req);
if (verbose) {
if (rsp == NULL) {
if (!rsp) {
lprintf(LOG_ERR, "Unable to send keystroke");
return -1;
}
@@ -429,7 +429,7 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv)
if (result <= 0) {
struct hostent *host = gethostbyname((const char *)intf->ssn_params.hostname);
if (host == NULL ) {
if (!host ) {
lprintf(LOG_ERR, "Address lookup for %s failed",
intf->ssn_params.hostname);
return -1;
@@ -459,7 +459,7 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv)
/*
* retrieve local IP address if not supplied on command line
*/
if (recvip == NULL) {
if (!recvip) {
/* must connect first */
result = intf->open(intf);
if (result < 0) {
@@ -475,7 +475,7 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv)
}
recvip = inet_ntoa(myaddr.sin_addr);
if (recvip == NULL) {
if (!recvip) {
lprintf(LOG_ERR, "Unable to find local IP address");
close(fd_socket);
return -1;