ipmi: Remove non-standard c++ array syntax
Change-Id: I1c62222ab8584ffc5af6d99c80b93f5e93b4e26f
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ipmi.cpp b/ipmi.cpp
index 976dbd2..f1f034c 100644
--- a/ipmi.cpp
+++ b/ipmi.cpp
@@ -113,7 +113,7 @@
* reply buffer size. */
reply->crc = 0;
/* Explicilty copies the NUL-terminator. */
- std::memcpy(&reply->blobId, blobId.c_str(), blobId.length() + 1);
+ std::memcpy(reply + 1, blobId.c_str(), blobId.length() + 1);
(*dataLen) = sizeof(reply->crc) + blobId.length() + 1;
@@ -128,8 +128,9 @@
uint16_t session;
(*dataLen) = 0;
- std::string path = stringFromBuffer(
- request->blobId, (requestLen - sizeof(struct BmcBlobOpenTx)));
+ std::string path =
+ stringFromBuffer(reinterpret_cast<const char*>(request + 1),
+ requestLen - sizeof(*request));
if (path.empty())
{
return IPMI_CC_REQ_DATA_LEN_INVALID;
@@ -174,8 +175,9 @@
auto request = reinterpret_cast<const struct BmcBlobDeleteTx*>(reqBuf);
(*dataLen) = 0;
- std::string path = stringFromBuffer(
- request->blobId, (requestLen - sizeof(struct BmcBlobDeleteTx)));
+ std::string path =
+ stringFromBuffer(reinterpret_cast<const char*>(request + 1),
+ requestLen - sizeof(*request));
if (path.empty())
{
return IPMI_CC_REQ_DATA_LEN_INVALID;
@@ -219,8 +221,9 @@
auto request = reinterpret_cast<const struct BmcBlobStatTx*>(reqBuf);
(*dataLen) = 0;
- std::string path = stringFromBuffer(
- request->blobId, (requestLen - sizeof(struct BmcBlobStatTx)));
+ std::string path =
+ stringFromBuffer(reinterpret_cast<const char*>(request + 1),
+ requestLen - sizeof(*request));
if (path.empty())
{
return IPMI_CC_REQ_DATA_LEN_INVALID;
@@ -268,7 +271,7 @@
}
std::vector<uint8_t> data(request->commitDataLen);
- std::memcpy(data.data(), request->commitData, request->commitDataLen);
+ std::memcpy(data.data(), request + 1, request->commitDataLen);
if (!mgr->commit(request->sessionId, data))
{
@@ -317,7 +320,7 @@
uint32_t size = requestLen - sizeof(struct BmcBlobWriteTx);
std::vector<uint8_t> data(size);
- std::memcpy(data.data(), request->data, size);
+ std::memcpy(data.data(), request + 1, size);
/* Attempt to write the bytes. */
if (!mgr->write(request->sessionId, request->offset, data))
diff --git a/ipmi.hpp b/ipmi.hpp
index b79b1ee..318498b 100644
--- a/ipmi.hpp
+++ b/ipmi.hpp
@@ -33,7 +33,6 @@
struct BmcBlobEnumerateRx
{
uint16_t crc;
- char blobId[];
} __attribute__((packed));
/* Used by bmcBlobOpen */
@@ -42,7 +41,6 @@
uint8_t cmd; /* bmcBlobOpen */
uint16_t crc;
uint16_t flags;
- char blobId[]; /* Must correspond to a valid blob. */
} __attribute__((packed));
struct BmcBlobOpenRx
@@ -64,7 +62,6 @@
{
uint8_t cmd; /* bmcBlobDelete */
uint16_t crc;
- char blobId[];
} __attribute__((packed));
/* Used by bmcBlobStat */
@@ -72,7 +69,6 @@
{
uint8_t cmd; /* bmcBlobStat */
uint16_t crc;
- char blobId[];
} __attribute__((packed));
struct BmcBlobStatRx
@@ -81,7 +77,6 @@
uint16_t blobState;
uint32_t size; /* Size in bytes of the blob. */
uint8_t metadataLen;
- uint8_t metadata[]; /* Optional blob-specific metadata. */
} __attribute__((packed));
/* Used by bmcBlobSessionStat */
@@ -99,7 +94,6 @@
uint16_t crc;
uint16_t sessionId;
uint8_t commitDataLen;
- uint8_t commitData[]; /* Optional blob-specific commit data. */
} __attribute__((packed));
/* Used by bmcBlobRead */
@@ -115,7 +109,6 @@
struct BmcBlobReadRx
{
uint16_t crc;
- uint8_t data[];
} __attribute__((packed));
/* Used by bmcBlobWrite */
@@ -125,7 +118,6 @@
uint16_t crc;
uint16_t sessionId;
uint32_t offset; /* The byte sequence start, 0-based. */
- uint8_t data[];
} __attribute__((packed));
/* Used by bmcBlobWriteMeta */
@@ -135,7 +127,6 @@
uint16_t crc;
uint16_t sessionId; /* Returned from BmcBlobOpen. */
uint32_t offset; /* The byte sequence start, 0-based. */
- uint8_t data[];
} __attribute__((packed));
/**
diff --git a/test/ipmi_commit_unittest.cpp b/test/ipmi_commit_unittest.cpp
index 37ec769..d4b9c58 100644
--- a/test/ipmi_commit_unittest.cpp
+++ b/test/ipmi_commit_unittest.cpp
@@ -100,7 +100,7 @@
req->crc = 0;
req->sessionId = 0x54;
req->commitDataLen = sizeof(expectedBlob);
- std::memcpy(req->commitData, &expectedBlob[0], sizeof(expectedBlob));
+ std::memcpy(req + 1, &expectedBlob[0], sizeof(expectedBlob));
dataLen = sizeof(struct BmcBlobCommitTx) + sizeof(expectedBlob);
diff --git a/test/ipmi_delete_unittest.cpp b/test/ipmi_delete_unittest.cpp
index afd3968..777e417 100644
--- a/test/ipmi_delete_unittest.cpp
+++ b/test/ipmi_delete_unittest.cpp
@@ -32,7 +32,7 @@
req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobDelete);
req->crc = 0;
// length() doesn't include the nul-terminator.
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobDeleteTx) + blobId.length();
@@ -55,7 +55,7 @@
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobDeleteTx) + blobId.length() + 1;
@@ -80,7 +80,7 @@
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobDeleteTx) + blobId.length() + 1;
diff --git a/test/ipmi_enumerate_unittest.cpp b/test/ipmi_enumerate_unittest.cpp
index 1474384..edea82b 100644
--- a/test/ipmi_enumerate_unittest.cpp
+++ b/test/ipmi_enumerate_unittest.cpp
@@ -61,6 +61,6 @@
EXPECT_EQ(blobId.length() + 1 + sizeof(uint16_t), dataLen);
rep = reinterpret_cast<struct BmcBlobEnumerateRx*>(reply);
- EXPECT_EQ(0, std::memcmp(rep->blobId, blobId.c_str(), blobId.length() + 1));
+ EXPECT_EQ(0, std::memcmp(rep + 1, blobId.c_str(), blobId.length() + 1));
}
} // namespace blobs
diff --git a/test/ipmi_open_unittest.cpp b/test/ipmi_open_unittest.cpp
index 8232340..5b18631 100644
--- a/test/ipmi_open_unittest.cpp
+++ b/test/ipmi_open_unittest.cpp
@@ -35,7 +35,7 @@
req->crc = 0;
req->flags = 0;
// length() doesn't include the nul-terminator.
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobOpenTx) + blobId.length();
@@ -59,7 +59,7 @@
req->flags = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobOpenTx) + blobId.length() + 1;
@@ -87,7 +87,7 @@
req->flags = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobOpenTx) + blobId.length() + 1;
uint16_t returnedSession = 0x54;
diff --git a/test/ipmi_stat_unittest.cpp b/test/ipmi_stat_unittest.cpp
index 083a980..6d4d7b2 100644
--- a/test/ipmi_stat_unittest.cpp
+++ b/test/ipmi_stat_unittest.cpp
@@ -35,7 +35,7 @@
req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat);
req->crc = 0;
// length() doesn't include the nul-terminator.
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobStatTx) + blobId.length();
@@ -58,7 +58,7 @@
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobStatTx) + blobId.length() + 1;
@@ -85,7 +85,7 @@
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobStatTx) + blobId.length() + 1;
@@ -127,7 +127,7 @@
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
- std::memcpy(req->blobId, blobId.c_str(), blobId.length());
+ std::memcpy(req + 1, blobId.c_str(), blobId.length());
dataLen = sizeof(struct BmcBlobStatTx) + blobId.length() + 1;
diff --git a/test/ipmi_write_unittest.cpp b/test/ipmi_write_unittest.cpp
index b249ccc..229ebd3 100644
--- a/test/ipmi_write_unittest.cpp
+++ b/test/ipmi_write_unittest.cpp
@@ -31,7 +31,7 @@
req->offset = 0x100;
uint8_t expectedBytes[2] = {0x66, 0x67};
- std::memcpy(req->data, &expectedBytes[0], sizeof(expectedBytes));
+ std::memcpy(req + 1, &expectedBytes[0], sizeof(expectedBytes));
dataLen = sizeof(struct BmcBlobWriteTx) + sizeof(expectedBytes);
@@ -60,7 +60,7 @@
req->offset = 0x100;
uint8_t expectedBytes[2] = {0x66, 0x67};
- std::memcpy(req->data, &expectedBytes[0], sizeof(expectedBytes));
+ std::memcpy(req + 1, &expectedBytes[0], sizeof(expectedBytes));
dataLen = sizeof(struct BmcBlobWriteTx) + sizeof(expectedBytes);
diff --git a/test/ipmi_writemeta_unittest.cpp b/test/ipmi_writemeta_unittest.cpp
index d137880..dd9e742 100644
--- a/test/ipmi_writemeta_unittest.cpp
+++ b/test/ipmi_writemeta_unittest.cpp
@@ -30,7 +30,7 @@
req->offset = 0x100;
uint8_t expectedBytes[2] = {0x66, 0x67};
- std::memcpy(req->data, &expectedBytes[0], sizeof(expectedBytes));
+ std::memcpy(req + 1, &expectedBytes[0], sizeof(expectedBytes));
dataLen = sizeof(struct BmcBlobWriteMetaTx) + sizeof(expectedBytes);
@@ -59,7 +59,7 @@
req->offset = 0x100;
uint8_t expectedBytes[2] = {0x66, 0x67};
- std::memcpy(req->data, &expectedBytes[0], sizeof(expectedBytes));
+ std::memcpy(req + 1, &expectedBytes[0], sizeof(expectedBytes));
dataLen = sizeof(struct BmcBlobWriteMetaTx) + sizeof(expectedBytes);
diff --git a/test/process_unittest.cpp b/test/process_unittest.cpp
index 8c133e5..47359cc 100644
--- a/test/process_unittest.cpp
+++ b/test/process_unittest.cpp
@@ -132,7 +132,7 @@
req->offset = 0x100;
uint8_t expectedBytes[2] = {0x66, 0x67};
- std::memcpy(req->data, &expectedBytes[0], sizeof(expectedBytes));
+ std::memcpy(req + 1, &expectedBytes[0], sizeof(expectedBytes));
dataLen = sizeof(struct BmcBlobWriteTx) + sizeof(expectedBytes);
@@ -161,7 +161,7 @@
req->offset = 0x100;
uint8_t expectedBytes[2] = {0x66, 0x67};
- std::memcpy(req->data, &expectedBytes[0], sizeof(expectedBytes));
+ std::memcpy(req + 1, &expectedBytes[0], sizeof(expectedBytes));
dataLen = sizeof(struct BmcBlobWriteTx) + sizeof(expectedBytes);