mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-06-29 16:51:35 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user