cgsecurity / testdisk

TestDisk & PhotoRec
https://www.cgsecurity.org/
GNU General Public License v2.0
1.58k stars 195 forks source link

src/common.h: fix le32(x) for big-endian architectures #15

Closed Deni90 closed 7 years ago

Deni90 commented 7 years ago

testdisk FTBFS on Debian for mips (and other big-endian architectures) with following error:

common.h:128:2: error: initializer element is not constant
  ((efi_guid_t){le32(0x516e7cb4),le16(0x6ecf),le16(0x11d6),0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}})
  ^
partgpt.c:80:5: note: in expansion of macro 'GPT_ENT_TYPE_FREEBSD'
   { GPT_ENT_TYPE_FREEBSD,  "FreeBSD"  },
     ^~~~~~~~~~~~~~~~~~~~
common.h:128:2: note: (near initialization for 'gpt_sys_types[2].part_type')
  ((efi_guid_t){le32(0x516e7cb4),le16(0x6ecf),le16(0x11d6),0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}})
  ^
partgpt.c:80:5: note: in expansion of macro 'GPT_ENT_TYPE_FREEBSD'
   { GPT_ENT_TYPE_FREEBSD,  "FreeBSD"  },
     ^~~~~~~~~~~~~~~~~~~~

build log: https://buildd.debian.org/status/fetch.php?pkg=testdisk&arch=mips&ver=7.0-2&stamp=1481458955

The problem was in bitwise with signed values in le32 macro.

With this patch I was able to build testdisk successfully on mips.