Move enum into zstd.h, and fix pesky switch() logic

dev
senhuang42 2020-08-21 18:18:53 -04:00
parent 1b34b15e6b
commit 47685ac856
4 changed files with 11 additions and 11 deletions

View File

@ -1398,9 +1398,9 @@ size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format)
return ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, format); return ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, format);
} }
size_t ZSTD_DCtx_setForceIgnoreChecksum(ZSTD_DCtx* dctx, ZSTD_format_e format) size_t ZSTD_DCtx_setForceIgnoreChecksum(ZSTD_DCtx* dctx, ZSTD_forceIgnoreChecksum_e shouldIgnore)
{ {
return ZSTD_DCtx_setParameter(dctx, ZSTD_d_forceIgnoreChecksum, format); return ZSTD_DCtx_setParameter(dctx, ZSTD_d_forceIgnoreChecksum, shouldIgnore);
} }
ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam) ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
@ -1423,6 +1423,7 @@ ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
case ZSTD_d_forceIgnoreChecksum: case ZSTD_d_forceIgnoreChecksum:
bounds.lowerBound = (int)ZSTD_d_validateChecksum; bounds.lowerBound = (int)ZSTD_d_validateChecksum;
bounds.upperBound = (int)ZSTD_d_ignoreChecksum; bounds.upperBound = (int)ZSTD_d_ignoreChecksum;
return bounds;
default:; default:;
} }
bounds.error = ERROR(parameter_unsupported); bounds.error = ERROR(parameter_unsupported);
@ -1465,6 +1466,7 @@ size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter dParam, int value
case ZSTD_d_forceIgnoreChecksum: case ZSTD_d_forceIgnoreChecksum:
CHECK_DBOUNDS(ZSTD_d_forceIgnoreChecksum, value); CHECK_DBOUNDS(ZSTD_d_forceIgnoreChecksum, value);
dctx->forceIgnoreChecksum = (ZSTD_forceIgnoreChecksum_e)value; dctx->forceIgnoreChecksum = (ZSTD_forceIgnoreChecksum_e)value;
return 0;
default:; default:;
} }
RETURN_ERROR(parameter_unsupported, ""); RETURN_ERROR(parameter_unsupported, "");

View File

@ -100,11 +100,6 @@ typedef enum {
ZSTD_obm_stable = 1 /* ZSTD_outBuffer is stable */ ZSTD_obm_stable = 1 /* ZSTD_outBuffer is stable */
} ZSTD_outBufferMode_e; } ZSTD_outBufferMode_e;
typedef enum {
ZSTD_d_validateChecksum = 0,
ZSTD_d_ignoreChecksum = 1
} ZSTD_forceIgnoreChecksum_e;
struct ZSTD_DCtx_s struct ZSTD_DCtx_s
{ {
const ZSTD_seqSymbol* LLTptr; const ZSTD_seqSymbol* LLTptr;

View File

@ -1162,6 +1162,11 @@ typedef enum {
* Decoder cannot recognise automatically this format, requiring this instruction. */ * Decoder cannot recognise automatically this format, requiring this instruction. */
} ZSTD_format_e; } ZSTD_format_e;
typedef enum {
ZSTD_d_validateChecksum = 0,
ZSTD_d_ignoreChecksum = 1
} ZSTD_forceIgnoreChecksum_e;
typedef enum { typedef enum {
/* Note: this enum and the behavior it controls are effectively internal /* Note: this enum and the behavior it controls are effectively internal
* implementation details of the compressor. They are expected to continue * implementation details of the compressor. They are expected to continue
@ -1712,7 +1717,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
/*! ZSTD_DCtx_setForceIgnoreChecksum() : /*! ZSTD_DCtx_setForceIgnoreChecksum() :
* Instruct the decoder context to ignore checksums in compressed frame. * Instruct the decoder context to ignore checksums in compressed frame.
* @return : 0, or an error code (which can be tested using ZSTD_isError()). */ * @return : 0, or an error code (which can be tested using ZSTD_isError()). */
ZSTDLIB_API size_t ZSTD_DCtx_setForceIgnoreChecksum(ZSTD_DCtx* dctx, ZSTD_format_e format); ZSTDLIB_API size_t ZSTD_DCtx_setForceIgnoreChecksum(ZSTD_DCtx* dctx, ZSTD_forceIgnoreChecksum_e format);
/*! ZSTD_decompressStream_simpleArgs() : /*! ZSTD_decompressStream_simpleArgs() :
* Same as ZSTD_decompressStream(), * Same as ZSTD_decompressStream(),

View File

@ -1754,10 +1754,8 @@ static dRess_t FIO_createDResources(FIO_prefs_t* const prefs, const char* dictFi
if (ress.dctx==NULL) if (ress.dctx==NULL)
EXM_THROW(60, "Error: %s : can't create ZSTD_DStream", strerror(errno)); EXM_THROW(60, "Error: %s : can't create ZSTD_DStream", strerror(errno));
CHECK( ZSTD_DCtx_setMaxWindowSize(ress.dctx, prefs->memLimit) ); CHECK( ZSTD_DCtx_setMaxWindowSize(ress.dctx, prefs->memLimit) );
if (!prefs->checksumFlag) { if (!prefs->checksumFlag)
DISPLAY("Ignoring checksums...");
CHECK( ZSTD_DCtx_setForceIgnoreChecksum(ress.dctx, 1 /* ZSTD_d_ignoreChecksum */)); CHECK( ZSTD_DCtx_setForceIgnoreChecksum(ress.dctx, 1 /* ZSTD_d_ignoreChecksum */));
}
ress.srcBufferSize = ZSTD_DStreamInSize(); ress.srcBufferSize = ZSTD_DStreamInSize();
ress.srcBuffer = malloc(ress.srcBufferSize); ress.srcBuffer = malloc(ress.srcBufferSize);
ress.dstBufferSize = ZSTD_DStreamOutSize(); ress.dstBufferSize = ZSTD_DStreamOutSize();