zero-initialize structs
Zero-initialize the structures used to send IPMI packets to the device
interface.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ic9c473ee2df7929bf309be63a8e9b9108ca8c2f2
diff --git a/src/ipmiblob/ipmi_handler.cpp b/src/ipmiblob/ipmi_handler.cpp
index 682fe45..39dc3aa 100644
--- a/src/ipmiblob/ipmi_handler.cpp
+++ b/src/ipmiblob/ipmi_handler.cpp
@@ -83,14 +83,13 @@
std::array<std::uint8_t, ipmiResponseBufferLen> responseBuffer;
/* Build address. */
- struct ipmi_system_interface_addr systemAddress;
+ ipmi_system_interface_addr systemAddress{};
systemAddress.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
systemAddress.channel = IPMI_BMC_CHANNEL;
systemAddress.lun = ipmiOEMLun;
/* Build request. */
- struct ipmi_req request;
- std::memset(&request, 0, sizeof(request));
+ ipmi_req request{};
request.addr = reinterpret_cast<unsigned char*>(&systemAddress);
request.addr_len = sizeof(systemAddress);
request.msgid = sequence++;
@@ -99,7 +98,7 @@
request.msg.netfn = netfn;
request.msg.cmd = cmd;
- struct ipmi_recv reply;
+ ipmi_recv reply{};
reply.addr = reinterpret_cast<unsigned char*>(&systemAddress);
reply.addr_len = sizeof(systemAddress);
reply.msg.data = reinterpret_cast<unsigned char*>(responseBuffer.data());
@@ -113,7 +112,7 @@
}
/* Could use sdeventplus, but for only one type of event is it worth it? */
- struct pollfd pfd;
+ pollfd pfd{};
pfd.fd = fd;
pfd.events = POLLIN;