]> www.infradead.org Git - users/sagi/nvme-cli.git/commit
util: Fix le128_to_cpu on little-endian
authorJinliang Wang <jinliangw@google.com>
Tue, 18 Oct 2022 23:41:13 +0000 (16:41 -0700)
committerJinliang Wang <jinliangw@google.com>
Wed, 19 Oct 2022 00:08:52 +0000 (17:08 -0700)
commit97c5cd547c2f180a1f7cf679c640627013be3f6f
treebd5fc68008f0816e5245e27cadda9e5939b59cb9
parent628e184cdedf772635d6b64d643a8f6627e5ad86
util: Fix le128_to_cpu on little-endian

We need to swap the words order in little-endian machine too.
For example:

uint128:  0x4000000030000000200000001

 0  1  2  3 |  4  5  6  7 | 8  9  a  b  | c  d  e  f
01 00 00 00 | 02 00 00 00 | 03 00 00 00 | 04 00 00 00

  w0(MSB)   |     w1      |    w2       |  w3(LSB)
04 00 00 00 | 03 00 00 00 | 02 00 00 00 | 01 00 00 00

Fixes: https://github.com/linux-nvme/nvme-cli/issues/1702
Signed-off-by: Jinliang Wang <jinliangw@google.com>
util/types.c