msgbuf: Improve type-specific ergonomics to match generic macros
Don't require that a pointer be passed. Rather, take the pointer inside
the type-safe macro definition, and perform the void cast to avoid the
alignment warning.
Change-Id: I5fbfc4a95591d2640595107e6f5fcae44a95950f
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/msgbuf.h b/src/msgbuf.h
index 6f50b05..2a03f05 100644
--- a/src/msgbuf.h
+++ b/src/msgbuf.h
@@ -415,7 +415,7 @@
*/
#define pldm_msgbuf_extract_uint8(ctx, dst) \
pldm_msgbuf_extract_typecheck(uint8_t, pldm__msgbuf_extract_uint8, \
- dst, ctx, dst)
+ dst, ctx, (void *)&(dst))
LIBPLDM_CC_NONNULL
LIBPLDM_CC_ALWAYS_INLINE int
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
@@ -443,7 +443,7 @@
#define pldm_msgbuf_extract_int8(ctx, dst) \
pldm_msgbuf_extract_typecheck(int8_t, pldm__msgbuf_extract_int8, dst, \
- ctx, dst)
+ ctx, (void *)&(dst))
LIBPLDM_CC_NONNULL
LIBPLDM_CC_ALWAYS_INLINE int
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
@@ -470,7 +470,7 @@
#define pldm_msgbuf_extract_uint16(ctx, dst) \
pldm_msgbuf_extract_typecheck(uint16_t, pldm__msgbuf_extract_uint16, \
- dst, ctx, dst)
+ dst, ctx, (void *)&(dst))
LIBPLDM_CC_NONNULL
LIBPLDM_CC_ALWAYS_INLINE int
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
@@ -522,7 +522,7 @@
#define pldm_msgbuf_extract_int16(ctx, dst) \
pldm_msgbuf_extract_typecheck(int16_t, pldm__msgbuf_extract_int16, \
- dst, ctx, dst)
+ dst, ctx, (void *)&(dst))
LIBPLDM_CC_NONNULL
LIBPLDM_CC_ALWAYS_INLINE int
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
@@ -559,7 +559,7 @@
#define pldm_msgbuf_extract_uint32(ctx, dst) \
pldm_msgbuf_extract_typecheck(uint32_t, pldm__msgbuf_extract_uint32, \
- dst, ctx, dst)
+ dst, ctx, (void *)&(dst))
LIBPLDM_CC_NONNULL
LIBPLDM_CC_ALWAYS_INLINE int
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
@@ -595,7 +595,7 @@
#define pldm_msgbuf_extract_int32(ctx, dst) \
pldm_msgbuf_extract_typecheck(int32_t, pldm__msgbuf_extract_int32, \
- dst, ctx, dst)
+ dst, ctx, (void *)&(dst))
LIBPLDM_CC_NONNULL
LIBPLDM_CC_ALWAYS_INLINE int
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
@@ -631,7 +631,7 @@
#define pldm_msgbuf_extract_real32(ctx, dst) \
pldm_msgbuf_extract_typecheck(real32_t, pldm__msgbuf_extract_real32, \
- dst, ctx, dst)
+ dst, ctx, (void *)&(dst))
LIBPLDM_CC_NONNULL
LIBPLDM_CC_ALWAYS_INLINE int
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
@@ -1347,7 +1347,7 @@
static inline int pldm_msgbuf_typecheck_uint8_t(struct pldm_msgbuf *ctx,
void *buf)
{
- static_assert(std::is_same<uint8_t *, T>::value);
+ static_assert(std::is_same<uint8_t, T>::value);
return pldm__msgbuf_extract_uint8(ctx, buf);
}
@@ -1355,7 +1355,7 @@
static inline int pldm_msgbuf_typecheck_int8_t(struct pldm_msgbuf *ctx,
void *buf)
{
- static_assert(std::is_same<int8_t *, T>::value);
+ static_assert(std::is_same<int8_t, T>::value);
return pldm__msgbuf_extract_int8(ctx, buf);
}
@@ -1363,7 +1363,7 @@
static inline int pldm_msgbuf_typecheck_uint16_t(struct pldm_msgbuf *ctx,
void *buf)
{
- static_assert(std::is_same<uint16_t *, T>::value);
+ static_assert(std::is_same<uint16_t, T>::value);
return pldm__msgbuf_extract_uint16(ctx, buf);
}
@@ -1371,7 +1371,7 @@
static inline int pldm_msgbuf_typecheck_int16_t(struct pldm_msgbuf *ctx,
void *buf)
{
- static_assert(std::is_same<int16_t *, T>::value);
+ static_assert(std::is_same<int16_t, T>::value);
return pldm__msgbuf_extract_int16(ctx, buf);
}
@@ -1379,7 +1379,7 @@
static inline int pldm_msgbuf_typecheck_uint32_t(struct pldm_msgbuf *ctx,
void *buf)
{
- static_assert(std::is_same<uint32_t *, T>::value);
+ static_assert(std::is_same<uint32_t, T>::value);
return pldm__msgbuf_extract_uint32(ctx, buf);
}
@@ -1387,7 +1387,7 @@
static inline int pldm_msgbuf_typecheck_int32_t(struct pldm_msgbuf *ctx,
void *buf)
{
- static_assert(std::is_same<int32_t *, T>::value);
+ static_assert(std::is_same<int32_t, T>::value);
return pldm__msgbuf_extract_int32(ctx, buf);
}
@@ -1395,7 +1395,7 @@
static inline int pldm_msgbuf_typecheck_real32_t(struct pldm_msgbuf *ctx,
void *buf)
{
- static_assert(std::is_same<real32_t *, T>::value);
+ static_assert(std::is_same<real32_t, T>::value);
return pldm__msgbuf_extract_real32(ctx, buf);
}
#endif
diff --git a/tests/dsp/platform.cpp b/tests/dsp/platform.cpp
index f94e5f7..2f0240b 100644
--- a/tests/dsp/platform.cpp
+++ b/tests/dsp/platform.cpp
@@ -1424,10 +1424,10 @@
uint32_t retDataTransferHandle;
uint16_t retEventIdToAcknowledge;
- pldm_msgbuf_extract_uint8(buf, &retFormatVersion);
- pldm_msgbuf_extract_uint8(buf, &retTransferOperationFlag);
- pldm_msgbuf_extract_uint32(buf, &retDataTransferHandle);
- pldm_msgbuf_extract_uint16(buf, &retEventIdToAcknowledge);
+ pldm_msgbuf_extract_uint8(buf, retFormatVersion);
+ pldm_msgbuf_extract_uint8(buf, retTransferOperationFlag);
+ pldm_msgbuf_extract_uint32(buf, retDataTransferHandle);
+ pldm_msgbuf_extract_uint16(buf, retEventIdToAcknowledge);
ASSERT_EQ(pldm_msgbuf_destroy_consumed(buf), 0);
EXPECT_EQ(retFormatVersion, formatVersion);
@@ -1463,10 +1463,10 @@
uint32_t retDataTransferHandle;
uint16_t retEventIdToAcknowledge;
- pldm_msgbuf_extract_uint8(buf, &retFormatVersion);
- pldm_msgbuf_extract_uint8(buf, &retTransferOperationFlag);
- pldm_msgbuf_extract_uint32(buf, &retDataTransferHandle);
- pldm_msgbuf_extract_uint16(buf, &retEventIdToAcknowledge);
+ pldm_msgbuf_extract_uint8(buf, retFormatVersion);
+ pldm_msgbuf_extract_uint8(buf, retTransferOperationFlag);
+ pldm_msgbuf_extract_uint32(buf, retDataTransferHandle);
+ pldm_msgbuf_extract_uint16(buf, retEventIdToAcknowledge);
ASSERT_EQ(pldm_msgbuf_destroy_consumed(buf), 0);
EXPECT_EQ(retFormatVersion, formatVersion);
@@ -1502,10 +1502,10 @@
uint32_t retDataTransferHandle;
uint16_t retEventIdToAcknowledge;
- pldm_msgbuf_extract_uint8(buf, &retFormatVersion);
- pldm_msgbuf_extract_uint8(buf, &retTransferOperationFlag);
- pldm_msgbuf_extract_uint32(buf, &retDataTransferHandle);
- pldm_msgbuf_extract_uint16(buf, &retEventIdToAcknowledge);
+ pldm_msgbuf_extract_uint8(buf, retFormatVersion);
+ pldm_msgbuf_extract_uint8(buf, retTransferOperationFlag);
+ pldm_msgbuf_extract_uint32(buf, retDataTransferHandle);
+ pldm_msgbuf_extract_uint16(buf, retEventIdToAcknowledge);
ASSERT_EQ(pldm_msgbuf_destroy_consumed(buf), 0);
EXPECT_EQ(retFormatVersion, formatVersion);
@@ -1965,17 +1965,17 @@
uint8_t retEventData[payloadLength] = {0};
uint32_t retEventDataIntegrityChecksum = 0;
- pldm_msgbuf_extract_uint8(buf, &retCompletionCode);
- pldm_msgbuf_extract_uint8(buf, &retTid);
- pldm_msgbuf_extract_uint16(buf, &retEventId);
- pldm_msgbuf_extract_uint32(buf, &retNextDataTransferHandle);
- pldm_msgbuf_extract_uint8(buf, &retTransferFlag);
- pldm_msgbuf_extract_uint8(buf, &retEventClass);
- pldm_msgbuf_extract_uint32(buf, &retEventDataSize);
+ pldm_msgbuf_extract_uint8(buf, retCompletionCode);
+ pldm_msgbuf_extract_uint8(buf, retTid);
+ pldm_msgbuf_extract_uint16(buf, retEventId);
+ pldm_msgbuf_extract_uint32(buf, retNextDataTransferHandle);
+ pldm_msgbuf_extract_uint8(buf, retTransferFlag);
+ pldm_msgbuf_extract_uint8(buf, retEventClass);
+ pldm_msgbuf_extract_uint32(buf, retEventDataSize);
rc = pldm_msgbuf_extract_array_uint8(buf, retEventDataSize, retEventData,
sizeof(retEventData));
ASSERT_EQ(rc, 0);
- pldm_msgbuf_extract_uint32(buf, &retEventDataIntegrityChecksum);
+ pldm_msgbuf_extract_uint32(buf, retEventDataIntegrityChecksum);
EXPECT_EQ(rc, PLDM_SUCCESS);
EXPECT_EQ(retCompletionCode, completionCode);
@@ -2020,9 +2020,9 @@
uint8_t retTid = 0;
uint16_t retEventId = 0;
- pldm_msgbuf_extract_uint8(buf, &retCompletionCode);
- pldm_msgbuf_extract_uint8(buf, &retTid);
- pldm_msgbuf_extract_uint16(buf, &retEventId);
+ pldm_msgbuf_extract_uint8(buf, retCompletionCode);
+ pldm_msgbuf_extract_uint8(buf, retTid);
+ pldm_msgbuf_extract_uint16(buf, retEventId);
EXPECT_EQ(rc, PLDM_SUCCESS);
EXPECT_EQ(retCompletionCode, completionCode);
@@ -2060,9 +2060,9 @@
uint8_t retTid = 0;
uint16_t retEventId = 0;
- pldm_msgbuf_extract_uint8(buf, &retCompletionCode);
- pldm_msgbuf_extract_uint8(buf, &retTid);
- pldm_msgbuf_extract_uint16(buf, &retEventId);
+ pldm_msgbuf_extract_uint8(buf, retCompletionCode);
+ pldm_msgbuf_extract_uint8(buf, retTid);
+ pldm_msgbuf_extract_uint16(buf, retEventId);
EXPECT_EQ(rc, PLDM_SUCCESS);
EXPECT_EQ(retCompletionCode, completionCode);
@@ -2114,14 +2114,14 @@
uint32_t retEventDataSize = 0;
uint32_t retEventDataIntegrityChecksum = 0;
- pldm_msgbuf_extract_uint8(buf, &retCompletionCode);
- pldm_msgbuf_extract_uint8(buf, &retTid);
- pldm_msgbuf_extract_uint16(buf, &retEventId);
- pldm_msgbuf_extract_uint32(buf, &retNextDataTransferHandle);
- pldm_msgbuf_extract_uint8(buf, &retTransferFlag);
- pldm_msgbuf_extract_uint8(buf, &retEventClass);
- pldm_msgbuf_extract_uint32(buf, &retEventDataSize);
- pldm_msgbuf_extract_uint32(buf, &retEventDataIntegrityChecksum);
+ pldm_msgbuf_extract_uint8(buf, retCompletionCode);
+ pldm_msgbuf_extract_uint8(buf, retTid);
+ pldm_msgbuf_extract_uint16(buf, retEventId);
+ pldm_msgbuf_extract_uint32(buf, retNextDataTransferHandle);
+ pldm_msgbuf_extract_uint8(buf, retTransferFlag);
+ pldm_msgbuf_extract_uint8(buf, retEventClass);
+ pldm_msgbuf_extract_uint32(buf, retEventDataSize);
+ pldm_msgbuf_extract_uint32(buf, retEventDataIntegrityChecksum);
EXPECT_EQ(rc, PLDM_SUCCESS);
EXPECT_EQ(retCompletionCode, completionCode);
@@ -2575,9 +2575,9 @@
uint16_t reteventID;
uint32_t retDataTransferHandle;
- EXPECT_EQ(pldm_msgbuf_extract_uint8(buf, &retFormatVersion), PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(buf, &reteventID), PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint32(buf, &retDataTransferHandle),
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(buf, retFormatVersion), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(buf, reteventID), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint32(buf, retDataTransferHandle),
PLDM_SUCCESS);
EXPECT_EQ(retFormatVersion, poll_event.format_version);
EXPECT_EQ(reteventID, poll_event.event_id);
diff --git a/tests/msgbuf.cpp b/tests/msgbuf.cpp
index 7ddd2fb..a65f6bb 100644
--- a/tests/msgbuf.cpp
+++ b/tests/msgbuf.cpp
@@ -72,7 +72,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, 0xa5);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -86,9 +86,9 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- ASSERT_EQ(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ ASSERT_EQ(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
ASSERT_EQ(val, 0xa5);
- EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -101,7 +101,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, 0x5a);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -115,7 +115,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, 0xa5);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -128,7 +128,7 @@
uint8_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -142,7 +142,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
ctx->remaining = INTMAX_MIN;
- EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -155,7 +155,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_int8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_int8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, -1);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -168,7 +168,7 @@
int8_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_int8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_int8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -182,7 +182,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
ctx->remaining = INTMAX_MIN;
- EXPECT_NE(pldm_msgbuf_extract_int8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_int8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -195,7 +195,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, 0x5aa5);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -210,7 +210,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
ctx->remaining = INTMAX_MIN + sizeof(val) - 1;
- EXPECT_NE(pldm_msgbuf_extract_uint16(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint16(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -222,7 +222,7 @@
uint16_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_uint16(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint16(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -235,7 +235,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_int16(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_int16(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, INT16_MIN);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -248,7 +248,7 @@
int16_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_int16(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_int16(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -262,7 +262,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
ctx->remaining = INTMAX_MIN + sizeof(val) - 1;
- EXPECT_NE(pldm_msgbuf_extract_int16(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_int16(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -275,7 +275,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, 0x5a00ffa5);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -288,7 +288,7 @@
uint32_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_uint32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -302,7 +302,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
ctx->remaining = INTMAX_MIN + sizeof(val) - 1;
- EXPECT_NE(pldm_msgbuf_extract_uint32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -315,7 +315,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_int32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_int32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, INT32_MIN);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -328,7 +328,7 @@
int32_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_int32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_int32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -342,7 +342,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
ctx->remaining = INTMAX_MIN + sizeof(val) - 1;
- EXPECT_NE(pldm_msgbuf_extract_int32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_int32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -361,7 +361,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, sizeof(buf), buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_real32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_real32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(val, FLT_MAX);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
}
@@ -374,7 +374,7 @@
real32_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_real32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_real32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -388,7 +388,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, 0), PLDM_SUCCESS);
ctx->remaining = INTMAX_MIN + sizeof(val) - 1;
- EXPECT_NE(pldm_msgbuf_extract_real32(ctx, &val), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_real32(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -516,7 +516,7 @@
uint8_t val;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, sizeof(buf)), PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, &val), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, val), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy_consumed(ctx), PLDM_SUCCESS);
}
@@ -525,11 +525,12 @@
struct pldm_msgbuf _ctx;
struct pldm_msgbuf* ctx = &_ctx;
uint8_t buf[1] = {};
- uint8_t val[2];
+ uint8_t valid;
+ uint8_t invalid;
ASSERT_EQ(pldm_msgbuf_init_cc(ctx, 0, buf, sizeof(buf)), PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, &val[0]), PLDM_SUCCESS);
- EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, &val[1]), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctx, valid), PLDM_SUCCESS);
+ EXPECT_NE(pldm_msgbuf_extract_uint8(ctx, invalid), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy_consumed(ctx), PLDM_ERROR_INVALID_LENGTH);
}
@@ -549,7 +550,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_int32(ctxExtract, &checkVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_int32(ctxExtract, checkVal), PLDM_SUCCESS);
EXPECT_EQ(src, checkVal);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
@@ -586,7 +587,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint32(ctxExtract, &checkVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint32(ctxExtract, checkVal), PLDM_SUCCESS);
EXPECT_EQ(src, checkVal);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
@@ -623,7 +624,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &checkVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, checkVal), PLDM_SUCCESS);
EXPECT_EQ(src, checkVal);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
@@ -660,7 +661,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_int16(ctxExtract, &checkVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_int16(ctxExtract, checkVal), PLDM_SUCCESS);
EXPECT_EQ(src, checkVal);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
@@ -697,7 +698,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, &checkVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, checkVal), PLDM_SUCCESS);
EXPECT_EQ(src, checkVal);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
@@ -734,7 +735,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_int8(ctxExtract, &checkVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_int8(ctxExtract, checkVal), PLDM_SUCCESS);
EXPECT_EQ(src, checkVal);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
@@ -858,7 +859,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_span_required(ctxExtract, required, (void**)&retBuff),
PLDM_SUCCESS);
@@ -887,7 +888,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_span_required(ctxExtract, required, NULL),
PLDM_SUCCESS);
@@ -921,11 +922,11 @@
char* retBuff = NULL;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(pldm_msgbuf_span_string_ascii(ctxExtract, (void**)&retBuff, NULL),
0);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, &testVal1), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, testVal1), 0);
EXPECT_EQ(0x77, testVal1);
EXPECT_EQ(required, strlen(retBuff) + 1);
@@ -946,12 +947,12 @@
size_t length;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(
pldm_msgbuf_span_string_ascii(ctxExtract, (void**)&retBuff, &length),
0);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, &testVal1), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, testVal1), 0);
EXPECT_EQ(0x77, testVal1);
EXPECT_EQ(required, strlen(retBuff) + 1);
@@ -969,7 +970,7 @@
uint16_t testVal;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(pldm_msgbuf_span_string_ascii(ctxExtract, NULL, NULL), 0);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), 0);
@@ -984,7 +985,7 @@
char* retBuff = NULL;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(pldm_msgbuf_span_string_ascii(ctxExtract, (void**)&retBuff, NULL),
-EOVERFLOW);
@@ -1030,12 +1031,12 @@
void* retBuff = NULL;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
ASSERT_EQ(pldm_msgbuf_span_string_utf16(ctxExtract, (void**)&retBuff, NULL),
0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal1), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal1), 0);
EXPECT_EQ(0x1234, testVal1);
ASSERT_EQ(0, (uintptr_t)retBuff & (alignof(char16_t) - 1));
@@ -1062,7 +1063,7 @@
size_t length = 0;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(pldm_msgbuf_span_string_utf16(ctxExtract, (void**)&retBuff, NULL),
@@ -1074,7 +1075,7 @@
sizeof(char16_t) * (str16len((char16_t*)retBuff) + 1)),
0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal1), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal1), 0);
EXPECT_EQ(0x1234, testVal1);
EXPECT_EQ(
@@ -1084,7 +1085,7 @@
EXPECT_EQ(0, length % 2);
EXPECT_EQ(memcmp(expectData1, retBuff1, length), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal1), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal1), 0);
EXPECT_EQ(0x1234, testVal1);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), 0);
@@ -1099,7 +1100,7 @@
uint16_t testVal;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(pldm_msgbuf_span_string_utf16(ctxExtract, NULL, NULL), 0);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), 0);
@@ -1115,7 +1116,7 @@
char16_t* retBuff = NULL;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(pldm_msgbuf_span_string_utf16(ctxExtract, (void**)&retBuff, NULL),
-EOVERFLOW);
@@ -1132,7 +1133,7 @@
char16_t* retBuff = NULL;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), 0);
EXPECT_EQ(0x2211, testVal);
EXPECT_EQ(pldm_msgbuf_span_string_utf16(ctxExtract, (void**)&retBuff, NULL),
-EOVERFLOW);
@@ -1170,7 +1171,7 @@
size_t length = 0;
ASSERT_EQ(pldm_msgbuf_init_errno(ctxExtract, 0, src, sizeof(src)), 0);
- EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, &name_count), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint8(ctxExtract, name_count), 0);
EXPECT_EQ(0x2, name_count);
EXPECT_EQ(pldm_msgbuf_span_string_ascii(ctxExtract, (void**)&tag, NULL), 0);
@@ -1203,7 +1204,7 @@
sizeof(char16_t) * (str16len((char16_t*)name2) + 1)),
0);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &test_val), 0);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, test_val), 0);
EXPECT_EQ(0x8877, test_val);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), 0);
@@ -1245,7 +1246,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), PLDM_SUCCESS);
EXPECT_EQ(
pldm_msgbuf_span_remaining(ctxExtract, (void**)&retBuff, &remaining),
PLDM_SUCCESS);
@@ -1274,7 +1275,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, testVal), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);
@@ -1300,7 +1301,7 @@
ASSERT_EQ(pldm_msgbuf_init_cc(dst, sizeof(buf1), buf1, sizeof(buf1)),
PLDM_SUCCESS);
- EXPECT_EQ(pldm_msgbuf_extract_uint16(dst, &checkVal), PLDM_SUCCESS);
+ EXPECT_EQ(pldm_msgbuf_extract_uint16(dst, checkVal), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(src), PLDM_SUCCESS);
EXPECT_EQ(pldm_msgbuf_destroy(dst), PLDM_SUCCESS);