From: Felix Fietkau Date: Sun, 14 Jun 2015 17:41:16 +0000 (+0000) Subject: firmware-tools/ptgen: fix endianness conversion for PTE .start, .length field. X-Git-Tag: reboot~2797 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=626356744406ec597f6ec5646c11f746e16538b9;p=openwrt%2Fstaging%2Fchunkeey.git firmware-tools/ptgen: fix endianness conversion for PTE .start, .length field. They are of 32-bit little endian integers. Signed-off-by: Yousong Zhou SVN-Revision: 45956 --- diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 6379ed7a59..68bad6fd97 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -31,9 +31,9 @@ #include #if __BYTE_ORDER == __BIG_ENDIAN -#define cpu_to_le16(x) bswap_16(x) +#define cpu_to_le32(x) bswap_32(x) #elif __BYTE_ORDER == __LITTLE_ENDIAN -#define cpu_to_le16(x) (x) +#define cpu_to_le32(x) (x) #else #error unknown endianness! #endif @@ -142,11 +142,11 @@ static int gen_ptable(uint32_t signature, int nr) start = sect + sectors; if (kb_align != 0) start = round_to_kb(start); - pte[i].start = cpu_to_le16(start); + pte[i].start = cpu_to_le32(start); sect = start + parts[i].size * 2; if (kb_align == 0) sect = round_to_cyl(sect); - pte[i].length = cpu_to_le16(len = sect - start); + pte[i].length = cpu_to_le32(len = sect - start); to_chs(start, pte[i].chs_start); to_chs(start + len - 1, pte[i].chs_end); if (verbose)