((uint32_t)(uint8_t)((buf)[2]) << 16) | \
((uint32_t)(uint8_t)((buf)[3]) << 24))
+/**
+ * virReadBufInt16BE:
+ * @buf: byte to start reading at (can be 'char*' or 'unsigned char*');
+ * evaluating buf must not have any side effects
+ *
+ * Read 2 bytes at BUF as a big-endian 16-bit number. Caller is
+ * responsible to avoid reading beyond array bounds.
+ */
+# define virReadBufInt16BE(buf) \
+ (((uint16_t)(uint8_t)((buf)[0]) << 8) | \
+ (uint16_t)(uint8_t)((buf)[1]))
+
+/**
+ * virReadBufInt16LE:
+ * @buf: byte to start reading at (can be 'char*' or 'unsigned char*');
+ * evaluating buf must not have any side effects
+ *
+ * Read 2 bytes at BUF as a little-endian 16-bit number. Caller is
+ * responsible to avoid reading beyond array bounds.
+ */
+# define virReadBufInt16LE(buf) \
+ ((uint16_t)(uint8_t)((buf)[0]) | \
+ ((uint16_t)(uint8_t)((buf)[1]) << 8))
+
#endif /* __VIR_ENDIAN_H__ */
if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
goto cleanup;
+ if (virReadBufInt16BE(array) != 0x0102U)
+ goto cleanup;
+ if (virReadBufInt16BE(array + 11) != 0x8c8dU)
+ goto cleanup;
+ if (virReadBufInt16LE(array) != 0x0201U)
+ goto cleanup;
+ if (virReadBufInt16LE(array + 11) != 0x8d8cU)
+ goto cleanup;
+
ret = 0;
cleanup:
return ret;
if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
goto cleanup;
+ if (virReadBufInt16BE(array) != 0x0102U)
+ goto cleanup;
+ if (virReadBufInt16BE(array + 11) != 0x8c8dU)
+ goto cleanup;
+ if (virReadBufInt16LE(array) != 0x0201U)
+ goto cleanup;
+ if (virReadBufInt16LE(array + 11) != 0x8d8cU)
+ goto cleanup;
+
ret = 0;
cleanup:
return ret;