From: Denis Vlasenko Date: Mon, 27 Nov 2006 16:48:17 +0000 (-0000) Subject: byteswap ops had extra mask ops - removed X-Git-Tag: 1_4_0~307 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=10d0d4eec7e3a292917f43f72afae20341d9ba11;p=oweals%2Fbusybox.git byteswap ops had extra mask ops - removed --- diff --git a/e2fsprogs/blkid/probe.h b/e2fsprogs/blkid/probe.h index e1b65246a..78f796419 100644 --- a/e2fsprogs/blkid/probe.h +++ b/e2fsprogs/blkid/probe.h @@ -327,8 +327,8 @@ _INLINE_ __u16 blkid_swab16(__u16 val) _INLINE_ __u64 blkid_swab64(__u64 val) { - return (blkid_swab32(val >> 32) | - (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32)); + return blkid_swab32(val >> 32) | + ( ((__u64)blkid_swab32((__u32)val)) << 32 ); } #endif @@ -341,14 +341,14 @@ _INLINE_ __u16 blkid_swab16(__u16 val) _INLINE_ __u32 blkid_swab32(__u32 val) { - return ((val>>24) | ((val>>8)&0xFF00) | - ((val<<8)&0xFF0000) | (val<<24)); + return (val>>24) | ((val>>8) & 0xFF00) | + ((val<<8) & 0xFF0000) | (val<<24); } _INLINE_ __u64 blkid_swab64(__u64 val) { - return (blkid_swab32(val >> 32) | - (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32)); + return blkid_swab32(val >> 32) | + ( ((__u64)blkid_swab32((__u32)val)) << 32 ); } #endif diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 74c7710da..07dac8bad 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -379,19 +379,19 @@ STATIC_OSF void xbsd_print_disklabel(int); #define SGI_XVM 0x0d #define SGI_ENTIRE_DISK SGI_VOLUME #if defined(CONFIG_FEATURE_SGI_LABEL) || defined(CONFIG_FEATURE_SUN_LABEL) -static unsigned short -__swap16(unsigned short x) +static uint16_t +__swap16(uint16_t x) { - return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8); + return (x << 8) | (x >> 8); } static uint32_t __swap32(uint32_t x) { - return (((x & 0xFF) << 24) | - ((x & 0xFF00) << 8) | - ((x & 0xFF0000) >> 8) | - ((x & 0xFF000000) >> 24)); + return (x << 24) | + ((x & 0xFF00) << 8) | + ((x & 0xFF0000) >> 8) | + (x >> 24); } #endif diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c index 9d444c0be..548a70bdc 100644 --- a/util-linux/fdisk_sgi.c +++ b/util-linux/fdisk_sgi.c @@ -84,10 +84,8 @@ typedef struct { #define SGI_INFO_MAGIC 0x00072959 #define SGI_INFO_MAGIC_SWAPPED 0x59290700 -#define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) \ - : (uint16_t)(x)) -#define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) \ - : (uint32_t)(x)) +#define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) : (uint16_t)(x)) +#define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) : (uint32_t)(x)) #define sgilabel ((sgi_partition *)MBRbuffer) #define sgiparam (sgilabel->devparam) diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c index 6973fbf30..1e8f2e525 100644 --- a/util-linux/fdisk_sun.c +++ b/util-linux/fdisk_sun.c @@ -2,10 +2,8 @@ #define SUN_LABEL_MAGIC 0xDABE #define SUN_LABEL_MAGIC_SWAPPED 0xBEDA -#define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) \ - : (uint16_t)(x)) -#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) \ - : (uint32_t)(x)) +#define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) : (uint16_t)(x)) +#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) : (uint32_t)(x)) /* Copied from linux/major.h */ #define FLOPPY_MAJOR 2