blobs-ipmid: use enum class for BlobOEMCommands
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ic5aa3e38b4df33a2cfa29c575f17097e38d06605
diff --git a/blobs-ipmid/blobs.hpp b/blobs-ipmid/blobs.hpp
index dbeac21..e75495b 100644
--- a/blobs-ipmid/blobs.hpp
+++ b/blobs-ipmid/blobs.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <cstdint>
#include <memory>
#include <string>
#include <vector>
@@ -7,7 +8,7 @@
namespace blobs
{
-enum BlobOEMCommands
+enum class BlobOEMCommands : std::uint8_t
{
bmcBlobGetCount = 0,
bmcBlobEnumerate = 1,
diff --git a/test/ipmi_close_unittest.cpp b/test/ipmi_close_unittest.cpp
index 2fa22b2..74a8efb 100644
--- a/test/ipmi_close_unittest.cpp
+++ b/test/ipmi_close_unittest.cpp
@@ -29,7 +29,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
struct BmcBlobCloseTx req;
- req.cmd = BlobOEMCommands::bmcBlobClose;
+ req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobClose);
req.crc = 0;
req.sessionId = sessionId;
@@ -53,7 +53,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
struct BmcBlobCloseTx req;
- req.cmd = BlobOEMCommands::bmcBlobClose;
+ req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobClose);
req.crc = 0;
req.sessionId = sessionId;
diff --git a/test/ipmi_commit_unittest.cpp b/test/ipmi_commit_unittest.cpp
index 85bd8f3..37ec769 100644
--- a/test/ipmi_commit_unittest.cpp
+++ b/test/ipmi_commit_unittest.cpp
@@ -27,7 +27,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobCommitTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobCommit;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobCommit);
req->crc = 0;
req->sessionId = 0x54;
req->commitDataLen =
@@ -49,7 +49,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobCommitTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobCommit;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobCommit);
req->crc = 0;
req->sessionId = 0x54;
req->commitDataLen = 0;
@@ -72,7 +72,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobCommitTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobCommit;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobCommit);
req->crc = 0;
req->sessionId = 0x54;
req->commitDataLen = 0;
@@ -96,7 +96,7 @@
uint8_t expectedBlob[4] = {0x25, 0x33, 0x45, 0x67};
- req->cmd = BlobOEMCommands::bmcBlobCommit;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobCommit);
req->crc = 0;
req->sessionId = 0x54;
req->commitDataLen = sizeof(expectedBlob);
diff --git a/test/ipmi_delete_unittest.cpp b/test/ipmi_delete_unittest.cpp
index 9145fe3..afd3968 100644
--- a/test/ipmi_delete_unittest.cpp
+++ b/test/ipmi_delete_unittest.cpp
@@ -29,7 +29,7 @@
auto req = reinterpret_cast<struct BmcBlobDeleteTx*>(request);
std::string blobId = "abc";
- req->cmd = BlobOEMCommands::bmcBlobDelete;
+ 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());
@@ -51,7 +51,7 @@
auto req = reinterpret_cast<struct BmcBlobDeleteTx*>(request);
std::string blobId = "a";
- req->cmd = BlobOEMCommands::bmcBlobDelete;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobDelete);
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
@@ -76,7 +76,7 @@
auto req = reinterpret_cast<struct BmcBlobDeleteTx*>(request);
std::string blobId = "a";
- req->cmd = BlobOEMCommands::bmcBlobDelete;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobDelete);
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
diff --git a/test/ipmi_enumerate_unittest.cpp b/test/ipmi_enumerate_unittest.cpp
index 3be56ba..1474384 100644
--- a/test/ipmi_enumerate_unittest.cpp
+++ b/test/ipmi_enumerate_unittest.cpp
@@ -25,7 +25,7 @@
struct BmcBlobEnumerateTx req;
uint8_t* request = reinterpret_cast<uint8_t*>(&req);
- req.cmd = BlobOEMCommands::bmcBlobEnumerate;
+ req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate);
req.blobIdx = 0;
dataLen = sizeof(struct BmcBlobEnumerateTx);
@@ -48,7 +48,7 @@
uint8_t* request = reinterpret_cast<uint8_t*>(&req);
std::string blobId = "/asdf";
- req.cmd = BlobOEMCommands::bmcBlobEnumerate;
+ req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate);
req.blobIdx = 0;
dataLen = sizeof(struct BmcBlobEnumerateTx);
diff --git a/test/ipmi_getcount_unittest.cpp b/test/ipmi_getcount_unittest.cpp
index c6d74e6..34fc33d 100644
--- a/test/ipmi_getcount_unittest.cpp
+++ b/test/ipmi_getcount_unittest.cpp
@@ -30,7 +30,7 @@
struct BmcBlobCountRx rep;
uint8_t* request = reinterpret_cast<uint8_t*>(&req);
- req.cmd = BlobOEMCommands::bmcBlobGetCount;
+ req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount);
dataLen = sizeof(req);
rep.crc = 0;
@@ -56,7 +56,7 @@
struct BmcBlobCountRx rep;
uint8_t* request = reinterpret_cast<uint8_t*>(&req);
- req.cmd = BlobOEMCommands::bmcBlobGetCount;
+ req.cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount);
dataLen = sizeof(req);
rep.crc = 0;
diff --git a/test/ipmi_open_unittest.cpp b/test/ipmi_open_unittest.cpp
index 9079df0..39ad426 100644
--- a/test/ipmi_open_unittest.cpp
+++ b/test/ipmi_open_unittest.cpp
@@ -31,7 +31,7 @@
auto req = reinterpret_cast<struct BmcBlobOpenTx*>(request);
std::string blobId = "abc";
- req->cmd = BlobOEMCommands::bmcBlobOpen;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobOpen);
req->crc = 0;
req->flags = 0;
// length() doesn't include the nul-terminator.
@@ -54,7 +54,7 @@
auto req = reinterpret_cast<struct BmcBlobOpenTx*>(request);
std::string blobId = "a";
- req->cmd = BlobOEMCommands::bmcBlobOpen;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobOpen);
req->crc = 0;
req->flags = 0;
// length() doesn't include the nul-terminator, request buff is initialized
@@ -82,7 +82,7 @@
struct BmcBlobOpenRx rep;
std::string blobId = "a";
- req->cmd = BlobOEMCommands::bmcBlobOpen;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobOpen);
req->crc = 0;
req->flags = 0;
// length() doesn't include the nul-terminator, request buff is initialized
diff --git a/test/ipmi_read_unittest.cpp b/test/ipmi_read_unittest.cpp
index b6dab55..8d1b55f 100644
--- a/test/ipmi_read_unittest.cpp
+++ b/test/ipmi_read_unittest.cpp
@@ -26,7 +26,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobReadTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobRead;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobRead);
req->crc = 0;
req->sessionId = 0x54;
req->offset = 0x100;
@@ -53,7 +53,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobReadTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobRead;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobRead);
req->crc = 0;
req->sessionId = 0x54;
req->offset = 0x100;
diff --git a/test/ipmi_sessionstat_unittest.cpp b/test/ipmi_sessionstat_unittest.cpp
index 1e4005e..875b6a8 100644
--- a/test/ipmi_sessionstat_unittest.cpp
+++ b/test/ipmi_sessionstat_unittest.cpp
@@ -27,7 +27,7 @@
uint8_t request[MAX_IPMI_BUFFER] = {0};
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobSessionStatTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobSessionStat;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobSessionStat);
req->crc = 0;
req->sessionId = 0x54;
@@ -50,7 +50,7 @@
uint8_t request[MAX_IPMI_BUFFER] = {0};
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobSessionStatTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobSessionStat;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobSessionStat);
req->crc = 0;
req->sessionId = 0x54;
@@ -85,7 +85,7 @@
uint8_t request[MAX_IPMI_BUFFER] = {0};
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobSessionStatTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobSessionStat;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobSessionStat);
req->crc = 0;
req->sessionId = 0x54;
diff --git a/test/ipmi_stat_unittest.cpp b/test/ipmi_stat_unittest.cpp
index cbff23d..b4f542d 100644
--- a/test/ipmi_stat_unittest.cpp
+++ b/test/ipmi_stat_unittest.cpp
@@ -32,7 +32,7 @@
auto req = reinterpret_cast<struct BmcBlobStatTx*>(request);
std::string blobId = "abc";
- req->cmd = BlobOEMCommands::bmcBlobStat;
+ 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());
@@ -54,7 +54,7 @@
auto req = reinterpret_cast<struct BmcBlobStatTx*>(request);
std::string blobId = "a";
- req->cmd = BlobOEMCommands::bmcBlobStat;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat);
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
@@ -81,7 +81,7 @@
auto req = reinterpret_cast<struct BmcBlobStatTx*>(request);
std::string blobId = "a";
- req->cmd = BlobOEMCommands::bmcBlobStat;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat);
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
@@ -120,7 +120,7 @@
auto req = reinterpret_cast<struct BmcBlobStatTx*>(request);
std::string blobId = "a";
- req->cmd = BlobOEMCommands::bmcBlobStat;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat);
req->crc = 0;
// length() doesn't include the nul-terminator, request buff is initialized
// to 0s
diff --git a/test/ipmi_write_unittest.cpp b/test/ipmi_write_unittest.cpp
index a42e266..b249ccc 100644
--- a/test/ipmi_write_unittest.cpp
+++ b/test/ipmi_write_unittest.cpp
@@ -25,7 +25,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobWriteTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobWrite;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite);
req->crc = 0;
req->sessionId = 0x54;
req->offset = 0x100;
@@ -54,7 +54,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobWriteTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobWrite;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite);
req->crc = 0;
req->sessionId = 0x54;
req->offset = 0x100;
diff --git a/test/ipmi_writemeta_unittest.cpp b/test/ipmi_writemeta_unittest.cpp
index 3542b23..d137880 100644
--- a/test/ipmi_writemeta_unittest.cpp
+++ b/test/ipmi_writemeta_unittest.cpp
@@ -24,7 +24,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobWriteMetaTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobWrite;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite);
req->crc = 0;
req->sessionId = 0x54;
req->offset = 0x100;
@@ -53,7 +53,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobWriteMetaTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobWrite;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite);
req->crc = 0;
req->sessionId = 0x54;
req->offset = 0x100;
diff --git a/test/process_unittest.cpp b/test/process_unittest.cpp
index d99bd21..1f5b0c3 100644
--- a/test/process_unittest.cpp
+++ b/test/process_unittest.cpp
@@ -90,7 +90,7 @@
uint8_t request[MAX_IPMI_BUFFER] = {0};
uint8_t reply[MAX_IPMI_BUFFER] = {0};
- request[0] = BlobOEMCommands::bmcBlobGetCount;
+ request[0] = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount);
dataLen = sizeof(uint8_t); // There is no payload for CRC.
ipmi_ret_t rc;
@@ -108,7 +108,7 @@
uint8_t request[MAX_IPMI_BUFFER] = {0};
uint8_t reply[MAX_IPMI_BUFFER] = {0};
- request[0] = BlobOEMCommands::bmcBlobGetCount;
+ request[0] = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount);
dataLen = sizeof(uint8_t) + sizeof(uint16_t);
// There is a payload, but there are insufficient bytes.
ipmi_ret_t rc;
@@ -126,7 +126,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobWriteTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobWrite;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite);
req->crc = 0x34;
req->sessionId = 0x54;
req->offset = 0x100;
@@ -155,7 +155,7 @@
uint8_t reply[MAX_IPMI_BUFFER] = {0};
auto req = reinterpret_cast<struct BmcBlobWriteTx*>(request);
- req->cmd = BlobOEMCommands::bmcBlobWrite;
+ req->cmd = static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite);
req->crc = 0x3412;
req->sessionId = 0x54;
req->offset = 0x100;