libpldm : Fix ver32 encoding declaration
This commit would attempt to fix the wrongly captured
ver32 structure declaration in libpldm & impacted test
cases.
Resolves : https://github.com/openbmc/pldm/issues/27
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I9dccd4377bb1ef0e7738527ff154fd75f6277f39
diff --git a/libpldm/pldm_types.h b/libpldm/pldm_types.h
index 3c5f086..e48cb8c 100644
--- a/libpldm/pldm_types.h
+++ b/libpldm/pldm_types.h
@@ -22,10 +22,10 @@
*
*/
typedef struct pldm_version {
- uint8_t major;
- uint8_t minor;
- uint8_t update;
uint8_t alpha;
+ uint8_t update;
+ uint8_t minor;
+ uint8_t major;
} __attribute__((packed)) ver32_t;
typedef uint8_t bool8_t;
diff --git a/libpldm/tests/libpldm_utils_test.cpp b/libpldm/tests/libpldm_utils_test.cpp
index 1b178d7..a6212c0 100644
--- a/libpldm/tests/libpldm_utils_test.cpp
+++ b/libpldm/tests/libpldm_utils_test.cpp
@@ -21,26 +21,32 @@
TEST(Ver2string, Ver2string)
{
- ver32_t version{0xf3, 0xf7, 0x10, 0x61};
+ ver32_t version{0x61, 0x10, 0xf7, 0xf3};
const char* vstr = "3.7.10a";
char buffer[1024];
auto rc = ver2str(&version, buffer, sizeof(buffer));
EXPECT_EQ(rc, (signed)std::strlen(vstr));
EXPECT_STREQ(vstr, buffer);
- version = {0x10, 0x01, 0xf7, 0x00};
+ version = {0x00, 0xf0, 0xf0, 0xf1};
+ vstr = "1.0.0";
+ rc = ver2str(&version, buffer, sizeof(buffer));
+ EXPECT_EQ(rc, (signed)std::strlen(vstr));
+ EXPECT_STREQ(vstr, buffer);
+
+ version = {0x00, 0xf7, 0x01, 0x10};
vstr = "10.01.7";
rc = ver2str(&version, buffer, sizeof(buffer));
EXPECT_EQ(rc, (signed)std::strlen(vstr));
EXPECT_STREQ(vstr, buffer);
- version = {0xf3, 0xf1, 0xff, 0x00};
+ version = {0x00, 0xff, 0xf1, 0xf3};
vstr = "3.1";
rc = ver2str(&version, buffer, sizeof(buffer));
EXPECT_EQ(rc, (signed)std::strlen(vstr));
EXPECT_STREQ(vstr, buffer);
- version = {0xf1, 0xf0, 0xff, 0x61};
+ version = {0x61, 0xff, 0xf0, 0xf1};
vstr = "1.0a";
rc = ver2str(&version, buffer, sizeof(buffer));
EXPECT_EQ(rc, (signed)std::strlen(vstr));
diff --git a/libpldmresponder/base.cpp b/libpldmresponder/base.cpp
index 572f8f1..4c5b757 100644
--- a/libpldmresponder/base.cpp
+++ b/libpldmresponder/base.cpp
@@ -60,12 +60,12 @@
};
static const std::map<Type, ver32_t> versions{
- {PLDM_BASE, {0xF1, 0xF0, 0xF0, 0x00}},
- {PLDM_PLATFORM, {0xF1, 0xF2, 0xF0, 0x00}},
- {PLDM_BIOS, {0xF1, 0xF0, 0xF0, 0x00}},
- {PLDM_FRU, {0xF1, 0xF0, 0xF0, 0x00}},
+ {PLDM_BASE, {0x00, 0xf0, 0xf0, 0xf1}},
+ {PLDM_PLATFORM, {0x00, 0xf0, 0xf2, 0xf1}},
+ {PLDM_BIOS, {0x00, 0xf0, 0xf0, 0xf1}},
+ {PLDM_FRU, {0x00, 0xf0, 0xf0, 0xf1}},
#ifdef OEM_IBM
- {PLDM_OEM, {0xF1, 0xF0, 0xF0, 0x00}},
+ {PLDM_OEM, {0x00, 0xf0, 0xf0, 0xf1}},
#endif
};
diff --git a/libpldmresponder/test/libpldmresponder_base_test.cpp b/libpldmresponder/test/libpldmresponder_base_test.cpp
index 9be09ff..3ef8006 100644
--- a/libpldmresponder/test/libpldmresponder_base_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_base_test.cpp
@@ -84,7 +84,7 @@
uint32_t transferHandle = 0x0;
uint8_t flag = PLDM_GET_FIRSTPART;
uint8_t retFlag = PLDM_START_AND_END;
- ver32_t version = {0xF1, 0xF0, 0xF0, 0x00};
+ ver32_t version = {0x00, 0xF0, 0xF0, 0xF1};
auto rc =
encode_get_version_req(0, transferHandle, flag, pldmType, request);