mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
open: swap free() calls for free_n()
Swap calls to free() with calls to free_n() to leverage helper method and handle clearing pointers after freeing in one step. Signed-off-by: Patrick Venture <venture@google.com>
This commit is contained in:
parent
51634fd77c
commit
df076b9547
@ -318,10 +318,7 @@ ipmi_openipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
|
|||||||
|
|
||||||
if (ioctl(intf->fd, IPMICTL_SEND_COMMAND, &_req) < 0) {
|
if (ioctl(intf->fd, IPMICTL_SEND_COMMAND, &_req) < 0) {
|
||||||
lperror(LOG_ERR, "Unable to send command");
|
lperror(LOG_ERR, "Unable to send command");
|
||||||
if (data) {
|
free_n(&data);
|
||||||
free(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,10 +327,7 @@ ipmi_openipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (intf->noanswer) {
|
if (intf->noanswer) {
|
||||||
if (data) {
|
free_n(&data);
|
||||||
free(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,25 +341,16 @@ ipmi_openipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
|
|||||||
} while (retval < 0 && errno == EINTR);
|
} while (retval < 0 && errno == EINTR);
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
lperror(LOG_ERR, "I/O Error");
|
lperror(LOG_ERR, "I/O Error");
|
||||||
if (data) {
|
free_n(&data);
|
||||||
free(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (retval == 0) {
|
} else if (retval == 0) {
|
||||||
lprintf(LOG_ERR, "No data available");
|
lprintf(LOG_ERR, "No data available");
|
||||||
if (data) {
|
free_n(&data);
|
||||||
free(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (FD_ISSET(intf->fd, &rset) == 0) {
|
if (FD_ISSET(intf->fd, &rset) == 0) {
|
||||||
lprintf(LOG_ERR, "No data available");
|
lprintf(LOG_ERR, "No data available");
|
||||||
if (data) {
|
free_n(&data);
|
||||||
free(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,10 +363,7 @@ ipmi_openipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
|
|||||||
if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) {
|
if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) {
|
||||||
lperror(LOG_ERR, "Error receiving message");
|
lperror(LOG_ERR, "Error receiving message");
|
||||||
if (errno != EMSGSIZE) {
|
if (errno != EMSGSIZE) {
|
||||||
if (data) {
|
free_n(&data);
|
||||||
free(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,10 +435,7 @@ ipmi_openipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
|
|||||||
rsp.data[rsp.data_len] = 0;
|
rsp.data[rsp.data_len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
free_n(&data);
|
||||||
free(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return &rsp;
|
return &rsp;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user