mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 16:47:28 +01:00
Fix some more -Wconversion warnings
This commit is contained in:
1 parent
665355bd8a
commit
3c86337cac
10 files changed
+382
-293
No files matched your search
@@ -92,12 +92,12 @@ wuffs_base__load_u8be(uint8_t* p) {
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__load_u16be(uint8_t* p) {
|
||||
return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0);
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__load_u16le(uint8_t* p) {
|
||||
return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -193,128 +193,128 @@ wuffs_base__store_u8be(uint8_t* p, uint8_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u16be(uint8_t* p, uint16_t x) {
|
||||
p[0] = x >> 8;
|
||||
p[1] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 8);
|
||||
p[1] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u16le(uint8_t* p, uint16_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u24be(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 16;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 16);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u24le(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u32be(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 24;
|
||||
p[1] = x >> 16;
|
||||
p[2] = x >> 8;
|
||||
p[3] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 24);
|
||||
p[1] = (uint8_t)(x >> 16);
|
||||
p[2] = (uint8_t)(x >> 8);
|
||||
p[3] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u32le(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u40be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 32;
|
||||
p[1] = x >> 24;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 8;
|
||||
p[4] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 32);
|
||||
p[1] = (uint8_t)(x >> 24);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 8);
|
||||
p[4] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u40le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u48be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 40;
|
||||
p[1] = x >> 32;
|
||||
p[2] = x >> 24;
|
||||
p[3] = x >> 16;
|
||||
p[4] = x >> 8;
|
||||
p[5] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 40);
|
||||
p[1] = (uint8_t)(x >> 32);
|
||||
p[2] = (uint8_t)(x >> 24);
|
||||
p[3] = (uint8_t)(x >> 16);
|
||||
p[4] = (uint8_t)(x >> 8);
|
||||
p[5] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u48le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u56be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 48;
|
||||
p[1] = x >> 40;
|
||||
p[2] = x >> 32;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 16;
|
||||
p[5] = x >> 8;
|
||||
p[6] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 48);
|
||||
p[1] = (uint8_t)(x >> 40);
|
||||
p[2] = (uint8_t)(x >> 32);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 16);
|
||||
p[5] = (uint8_t)(x >> 8);
|
||||
p[6] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u56le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[6] = x >> 48;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
p[6] = (uint8_t)(x >> 48);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u64be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 56;
|
||||
p[1] = x >> 48;
|
||||
p[2] = x >> 40;
|
||||
p[3] = x >> 32;
|
||||
p[4] = x >> 24;
|
||||
p[5] = x >> 16;
|
||||
p[6] = x >> 8;
|
||||
p[7] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 56);
|
||||
p[1] = (uint8_t)(x >> 48);
|
||||
p[2] = (uint8_t)(x >> 40);
|
||||
p[3] = (uint8_t)(x >> 32);
|
||||
p[4] = (uint8_t)(x >> 24);
|
||||
p[5] = (uint8_t)(x >> 16);
|
||||
p[6] = (uint8_t)(x >> 8);
|
||||
p[7] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u64le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[6] = x >> 48;
|
||||
p[7] = x >> 56;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
p[6] = (uint8_t)(x >> 48);
|
||||
p[7] = (uint8_t)(x >> 56);
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
@@ -59,7 +59,7 @@ wuffs_base__pixel_swizzler__copy_4_1(wuffs_base__slice_u8 dst,
|
||||
|
||||
s += 1 * N;
|
||||
d += 4 * N;
|
||||
n -= 1 * N;
|
||||
n -= (size_t)(1 * N);
|
||||
}
|
||||
|
||||
while (n >= 1) {
|
||||
@@ -69,7 +69,7 @@ wuffs_base__pixel_swizzler__copy_4_1(wuffs_base__slice_u8 dst,
|
||||
|
||||
s += 1 * 1;
|
||||
d += 4 * 1;
|
||||
n -= 1 * 1;
|
||||
n -= (size_t)(1 * 1);
|
||||
}
|
||||
|
||||
return len;
|
||||
|
||||
@@ -74,11 +74,11 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w,
|
||||
return 0;
|
||||
}
|
||||
uint8_t* q = p - distance;
|
||||
size_t n = io1_w - p;
|
||||
size_t n = (size_t)(io1_w - p);
|
||||
if ((size_t)(length) > n) {
|
||||
length = n;
|
||||
length = (uint32_t)(n);
|
||||
} else {
|
||||
n = length;
|
||||
n = (size_t)(length);
|
||||
}
|
||||
// TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that
|
||||
// is mostly because 3 is the minimum length for the deflate format. This
|
||||
@@ -138,18 +138,18 @@ wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = length;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
uint8_t* iop_r = *ptr_iop_r;
|
||||
if (n > ((size_t)(io1_r - iop_r))) {
|
||||
n = io1_r - iop_r;
|
||||
n = (size_t)(io1_r - iop_r);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, iop_r, n);
|
||||
*ptr_iop_w += n;
|
||||
*ptr_iop_r += n;
|
||||
}
|
||||
return n;
|
||||
return (uint32_t)(n);
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
@@ -159,13 +159,13 @@ wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
return (uint64_t)(n);
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -179,13 +179,13 @@ wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,
|
||||
n = length;
|
||||
}
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
return (uint32_t)(n);
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
|
||||
Reference in new issue
Block a user