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));