From: Michael Buesch Date: Mon, 19 Apr 2010 16:17:55 +0000 (+0200) Subject: b43-fwcutter: Fix compiler warnings X-Git-Tag: b43-fwcutter-014~50 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=a73ba526c3bd9f4e95cc95808d7487607c651cd0;p=b43-tools.git b43-fwcutter: Fix compiler warnings "Type punned pointer blah blah..." Just call the "from_..." functions from the "to_..." functions. They also work backwards. Signed-off-by: Michael Buesch --- diff --git a/fwcutter/fwcutter.c b/fwcutter/fwcutter.c index 0d82806..79e351f 100644 --- a/fwcutter/fwcutter.c +++ b/fwcutter/fwcutter.c @@ -65,18 +65,6 @@ static int file_ok(const struct file *f) return !(f->flags & FW_FLAG_UNSUPPORTED) || cmdargs.unsupported; } -/* Convert a CPU-endian 16bit integer to Big-Endian */ -static be16_t to_be16(uint16_t v) -{ - uint8_t ret[2]; - - ret[0] = (v & 0xFF00) >> 8; - ret[1] = (v & 0x00FF); - - return *((be16_t *)ret); -} - -#if 0 /* Convert a Big-Endian 16bit integer to CPU-endian */ static uint16_t from_be16(be16_t v) { @@ -87,19 +75,11 @@ static uint16_t from_be16(be16_t v) return ret; } -#endif -/* Convert a CPU-endian 32bit integer to Big-Endian */ -static be32_t to_be32(uint32_t v) +/* Convert a CPU-endian 16bit integer to Big-Endian */ +static be16_t to_be16(uint16_t v) { - uint8_t ret[4]; - - ret[0] = (v & 0xFF000000) >> 24; - ret[1] = (v & 0x00FF0000) >> 16; - ret[2] = (v & 0x0000FF00) >> 8; - ret[3] = (v & 0x000000FF); - - return *((be32_t *)ret); + return (be16_t)from_be16((be16_t)v); } /* Convert a Big-Endian 32bit integer to CPU-endian */ @@ -115,6 +95,12 @@ static uint32_t from_be32(be32_t v) return ret; } +/* Convert a CPU-endian 32bit integer to Big-Endian */ +static be32_t to_be32(uint32_t v) +{ + return (be32_t)from_be32((be32_t)v); +} + /* tiny disassembler */ static void print_ucode_version(struct insn *insn) {