fixed warnings in testpools
This commit is contained in:
@@ -994,6 +994,13 @@ typedef struct {
|
|||||||
} seqState_t;
|
} seqState_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* ZSTD_execSequenceLast7():
|
||||||
|
* exceptional case : decompress a match starting within last 7 bytes of output buffer.
|
||||||
|
* requires more careful checks, to ensure there is no overflow.
|
||||||
|
* performance does not matter though.
|
||||||
|
* note : this case is supposed to be never generated "naturally" by reference encoder,
|
||||||
|
* since in most cases it needs at least 8 bytes to look for a match.
|
||||||
|
* but it's allowed by the specification. */
|
||||||
FORCE_NOINLINE
|
FORCE_NOINLINE
|
||||||
size_t ZSTD_execSequenceLast7(BYTE* op,
|
size_t ZSTD_execSequenceLast7(BYTE* op,
|
||||||
BYTE* const oend, seq_t sequence,
|
BYTE* const oend, seq_t sequence,
|
||||||
@@ -1003,21 +1010,14 @@ size_t ZSTD_execSequenceLast7(BYTE* op,
|
|||||||
BYTE* const oLitEnd = op + sequence.litLength;
|
BYTE* const oLitEnd = op + sequence.litLength;
|
||||||
size_t const sequenceLength = sequence.litLength + sequence.matchLength;
|
size_t const sequenceLength = sequence.litLength + sequence.matchLength;
|
||||||
BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
|
BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
|
||||||
BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH;
|
|
||||||
const BYTE* const iLitEnd = *litPtr + sequence.litLength;
|
const BYTE* const iLitEnd = *litPtr + sequence.litLength;
|
||||||
const BYTE* match = oLitEnd - sequence.offset;
|
const BYTE* match = oLitEnd - sequence.offset;
|
||||||
|
|
||||||
/* check */
|
/* check */
|
||||||
if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
|
if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must fit within dstBuffer */
|
||||||
if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
|
if (iLitEnd > litLimit) return ERROR(corruption_detected); /* try to read beyond literal buffer */
|
||||||
if (oLitEnd <= oend_w) return ERROR(GENERIC); /* Precondition */
|
|
||||||
|
|
||||||
/* copy literals */
|
/* copy literals */
|
||||||
if (op < oend_w) {
|
|
||||||
ZSTD_wildcopy(op, *litPtr, oend_w - op);
|
|
||||||
*litPtr += oend_w - op;
|
|
||||||
op = oend_w;
|
|
||||||
}
|
|
||||||
while (op < oLitEnd) *op++ = *(*litPtr)++;
|
while (op < oLitEnd) *op++ = *(*litPtr)++;
|
||||||
|
|
||||||
/* copy Match */
|
/* copy Match */
|
||||||
|
|||||||
+6
-6
@@ -30,7 +30,7 @@ struct data {
|
|||||||
size_t i;
|
size_t i;
|
||||||
};
|
};
|
||||||
|
|
||||||
void fn(void *opaque) {
|
static void fn(void *opaque) {
|
||||||
struct data *data = (struct data *)opaque;
|
struct data *data = (struct data *)opaque;
|
||||||
ZSTD_pthread_mutex_lock(&data->mutex);
|
ZSTD_pthread_mutex_lock(&data->mutex);
|
||||||
data->data[data->i] = data->i;
|
data->data[data->i] = data->i;
|
||||||
@@ -38,7 +38,7 @@ void fn(void *opaque) {
|
|||||||
ZSTD_pthread_mutex_unlock(&data->mutex);
|
ZSTD_pthread_mutex_unlock(&data->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int testOrder(size_t numThreads, size_t queueSize) {
|
static int testOrder(size_t numThreads, size_t queueSize) {
|
||||||
struct data data;
|
struct data data;
|
||||||
POOL_ctx *ctx = POOL_create(numThreads, queueSize);
|
POOL_ctx *ctx = POOL_create(numThreads, queueSize);
|
||||||
ASSERT_TRUE(ctx);
|
ASSERT_TRUE(ctx);
|
||||||
@@ -63,13 +63,13 @@ int testOrder(size_t numThreads, size_t queueSize) {
|
|||||||
|
|
||||||
/* --- test deadlocks --- */
|
/* --- test deadlocks --- */
|
||||||
|
|
||||||
void waitFn(void *opaque) {
|
static void waitFn(void *opaque) {
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
UTIL_sleepMilli(1);
|
UTIL_sleepMilli(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tests for deadlock */
|
/* Tests for deadlock */
|
||||||
int testWait(size_t numThreads, size_t queueSize) {
|
static int testWait(size_t numThreads, size_t queueSize) {
|
||||||
struct data data;
|
struct data data;
|
||||||
POOL_ctx *ctx = POOL_create(numThreads, queueSize);
|
POOL_ctx *ctx = POOL_create(numThreads, queueSize);
|
||||||
ASSERT_TRUE(ctx);
|
ASSERT_TRUE(ctx);
|
||||||
@@ -92,7 +92,7 @@ typedef struct {
|
|||||||
ZSTD_pthread_cond_t cond;
|
ZSTD_pthread_cond_t cond;
|
||||||
} poolTest_t;
|
} poolTest_t;
|
||||||
|
|
||||||
void waitLongFn(void *opaque) {
|
static void waitLongFn(void *opaque) {
|
||||||
poolTest_t* test = (poolTest_t*) opaque;
|
poolTest_t* test = (poolTest_t*) opaque;
|
||||||
UTIL_sleepMilli(10);
|
UTIL_sleepMilli(10);
|
||||||
ZSTD_pthread_mutex_lock(&test->mut);
|
ZSTD_pthread_mutex_lock(&test->mut);
|
||||||
@@ -167,7 +167,7 @@ typedef struct {
|
|||||||
int val;
|
int val;
|
||||||
} abruptEndCanary_t;
|
} abruptEndCanary_t;
|
||||||
|
|
||||||
void waitIncFn(void *opaque) {
|
static void waitIncFn(void *opaque) {
|
||||||
abruptEndCanary_t* test = (abruptEndCanary_t*) opaque;
|
abruptEndCanary_t* test = (abruptEndCanary_t*) opaque;
|
||||||
UTIL_sleepMilli(10);
|
UTIL_sleepMilli(10);
|
||||||
ZSTD_pthread_mutex_lock(&test->mut);
|
ZSTD_pthread_mutex_lock(&test->mut);
|
||||||
|
|||||||
Reference in New Issue
Block a user