platform: pldm_msgbuf for decode_set_numeric_effecter_value_req()

Also, make it at least possible to detect incorrect use of the API by
declaring `effecter_value` as a fixed-size array of 4.
Misuse is detected by -Wstringop-overflow with `gcc`, however failure
to uphold the requirement is ignored by `g++`, and both `clang` and
`clang++`.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I5769db4d3c812d7feef994de836a8621fb4bf3cf
diff --git a/src/msgbuf/platform.h b/src/msgbuf/platform.h
index c10dc45..69403db 100644
--- a/src/msgbuf/platform.h
+++ b/src/msgbuf/platform.h
@@ -73,4 +73,28 @@
 	return -PLDM_ERROR_INVALID_DATA;
 }
 
+/* This API is bad, but it's because the caller's APIs are also bad */
+__attribute__((always_inline)) static inline int
+pldm_msgbuf_extract_effecter_value(struct pldm_msgbuf *ctx,
+				   enum pldm_effecter_data_size tag,
+				   uint8_t *val)
+{
+	switch (tag) {
+	case PLDM_EFFECTER_DATA_SIZE_UINT8:
+		return pldm_msgbuf_extract_uint8(ctx, (uint8_t *)val);
+	case PLDM_EFFECTER_DATA_SIZE_SINT8:
+		return pldm_msgbuf_extract_int8(ctx, (int8_t *)val);
+	case PLDM_EFFECTER_DATA_SIZE_UINT16:
+		return pldm_msgbuf_extract_uint16(ctx, (uint16_t *)val);
+	case PLDM_EFFECTER_DATA_SIZE_SINT16:
+		return pldm_msgbuf_extract_int16(ctx, (int16_t *)val);
+	case PLDM_EFFECTER_DATA_SIZE_UINT32:
+		return pldm_msgbuf_extract_uint32(ctx, (uint32_t *)val);
+	case PLDM_EFFECTER_DATA_SIZE_SINT32:
+		return pldm_msgbuf_extract_int32(ctx, (int32_t *)val);
+	}
+
+	return -PLDM_ERROR_INVALID_DATA;
+}
+
 #endif