Skip to content

Commit db2d205

Browse files
committed
fixed -Wconversion for lib/decompress/zstd_decompress_block.c
1 parent 2413f17 commit db2d205

File tree

4 files changed

+71
-63
lines changed

4 files changed

+71
-63
lines changed

lib/common/compiler.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ ptrdiff_t ZSTD_wrappedPtrDiff(unsigned char const* lhs, unsigned char const* rhs
357357
*/
358358
MEM_STATIC
359359
ZSTD_ALLOW_POINTER_OVERFLOW_ATTR
360-
unsigned char const* ZSTD_wrappedPtrAdd(unsigned char const* ptr, ptrdiff_t add)
360+
const void* ZSTD_wrappedPtrAdd(const void* ptr, ptrdiff_t add)
361361
{
362-
return ptr + add;
362+
return (const char*)ptr + add;
363363
}
364364

365365
/**
@@ -370,9 +370,9 @@ unsigned char const* ZSTD_wrappedPtrAdd(unsigned char const* ptr, ptrdiff_t add)
370370
*/
371371
MEM_STATIC
372372
ZSTD_ALLOW_POINTER_OVERFLOW_ATTR
373-
unsigned char const* ZSTD_wrappedPtrSub(unsigned char const* ptr, ptrdiff_t sub)
373+
const void* ZSTD_wrappedPtrSub(const void* ptr, ptrdiff_t sub)
374374
{
375-
return ptr - sub;
375+
return (const char*)ptr - sub;
376376
}
377377

378378
/**
@@ -382,9 +382,9 @@ unsigned char const* ZSTD_wrappedPtrSub(unsigned char const* ptr, ptrdiff_t sub)
382382
* @returns `ptr + add` except it defines `NULL + 0 == NULL`.
383383
*/
384384
MEM_STATIC
385-
unsigned char* ZSTD_maybeNullPtrAdd(unsigned char* ptr, ptrdiff_t add)
385+
void* ZSTD_maybeNullPtrAdd(void* ptr, ptrdiff_t add)
386386
{
387-
return add > 0 ? ptr + add : ptr;
387+
return add > 0 ? (char*)ptr + add : ptr;
388388
}
389389

390390
/* Issue #3240 reports an ASAN failure on an llvm-mingw build. Out of an

lib/common/zstd_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ typedef enum {
213213
* The src buffer must be before the dst buffer.
214214
*/
215215
MEM_STATIC FORCE_INLINE_ATTR
216-
void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
216+
void ZSTD_wildcopy(void* dst, const void* src, size_t length, ZSTD_overlap_e const ovtype)
217217
{
218218
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
219219
const BYTE* ip = (const BYTE*)src;

lib/compress/zstd_compress_internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ ZSTD_safecopyLiterals(BYTE* op, BYTE const* ip, BYTE const* const iend, BYTE con
707707
{
708708
assert(iend > ilimit_w);
709709
if (ip <= ilimit_w) {
710-
ZSTD_wildcopy(op, ip, ilimit_w - ip, ZSTD_no_overlap);
710+
ZSTD_wildcopy(op, ip, (size_t)(ilimit_w - ip), ZSTD_no_overlap);
711711
op += ilimit_w - ip;
712712
ip = ilimit_w;
713713
}
@@ -800,7 +800,7 @@ ZSTD_storeSeq(SeqStore_t* seqStorePtr,
800800
ZSTD_STATIC_ASSERT(WILDCOPY_OVERLENGTH >= 16);
801801
ZSTD_copy16(seqStorePtr->lit, literals);
802802
if (litLength > 16) {
803-
ZSTD_wildcopy(seqStorePtr->lit+16, literals+16, (ptrdiff_t)litLength-16, ZSTD_no_overlap);
803+
ZSTD_wildcopy(seqStorePtr->lit+16, literals+16, litLength-16, ZSTD_no_overlap);
804804
}
805805
} else {
806806
ZSTD_safecopyLiterals(seqStorePtr->lit, literals, litEnd, litLimit_w);

0 commit comments

Comments
 (0)