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

@@ -101,7 +101,7 @@ ipmi_master_write_read(struct ipmi_intf * intf, uint8_t bus, uint8_t addr,
}
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
if (!rsp) {
lprintf(LOG_ERR, "I2C Master Write-Read command failed");
return NULL;
}
@@ -171,7 +171,7 @@ ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv)
for (i = 0; i < RAW_SPD_SIZE; i+= msize) {
rsp = ipmi_master_write_read(intf, i2cbus, i2caddr,
(uint8_t *)&i, 1, msize );
if (rsp == NULL) {
if (!rsp) {
lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read");
return -1;
}
@@ -259,7 +259,7 @@ ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
printbuf(wdata, wsize, "WRITE DATA");
rsp = ipmi_master_write_read(intf, bus, i2caddr, wdata, wsize, rsize);
if (rsp == NULL) {
if (!rsp) {
lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read");
return -1;
}
@@ -379,7 +379,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
if (!rsp) {
lprintf(LOG_ERR, "Unable to send RAW command "
"(channel=0x%x netfn=0x%x lun=0x%x cmd=0x%x)",
intf->target_channel & 0x0f, req.msg.netfn, req.msg.lun, req.msg.cmd);
@@ -417,7 +417,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
*/
int
is_valid_param(const char *input_param, uint8_t *uchr_ptr, const char *label) {
if (input_param == NULL || label == NULL) {
if (!input_param || !label) {
lprintf(LOG_ERROR, "ERROR: NULL pointer passed.");
return (-1);
}