Skip to content

Commit

Permalink
assert if type is zero
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Gottschall <[email protected]>
  • Loading branch information
BrainSlayer committed Dec 4, 2019
1 parent 97bf53b commit a967990
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions module/zstd/zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static const ZSTD_customMem zstd_dctx_malloc = {

enum zstd_kmem_type {
ZSTD_KMEM_UNKNOWN = 0,
ZSTD_KMEM_DEFAULT,
ZSTD_KMEM_POOL,
ZSTD_KMEM_DCTX,
ZSTD_KMEM_COUNT,
Expand Down Expand Up @@ -249,7 +250,7 @@ zstd_mempool_alloc(struct zstd_pool *zstd_mempool, size_t size)
mem = vmem_alloc(size, KM_NOSLEEP);
if (mem) {
mem->pool = NULL;
mem->kmem_type = ZSTD_KMEM_UNKNOWN;
mem->kmem_type = ZSTD_KMEM_DEFAULT;
mem->kmem_size = size;
}
} else {
Expand Down Expand Up @@ -578,7 +579,7 @@ zstd_dctx_alloc(void *opaque __unused, size_t size)
{
size_t nbytes = sizeof (struct zstd_kmem) + size;
struct zstd_kmem *z = NULL;
enum zstd_kmem_type type = ZSTD_KMEM_UNKNOWN;
enum zstd_kmem_type type = ZSTD_KMEM_DEFAULT;

z = (struct zstd_kmem *)zstd_mempool_alloc(zstd_mempool_dctx, nbytes);
if (!z) {
Expand Down Expand Up @@ -619,7 +620,7 @@ zstd_free(void *opaque __unused, void *ptr)
enum zstd_kmem_type type;

ASSERT3U(z->kmem_type, <, ZSTD_KMEM_COUNT);
ASSERT3U(z->kmem_type, >=, ZSTD_KMEM_UNKNOWN);
ASSERT3U(z->kmem_type, >, ZSTD_KMEM_UNKNOWN);
type = z->kmem_type;
switch (type) {
case ZSTD_KMEM_UNKNOWN:
Expand Down

0 comments on commit a967990

Please sign in to comment.