mirror of
https://github.com/google/brotli.git
synced 2024-11-09 21:50:07 +00:00
Fix "unused function" warning.
This commit is contained in:
parent
bb6f5fea46
commit
639fdaf62d
24
dec/decode.c
24
dec/decode.c
@ -170,7 +170,7 @@ static BROTLI_NOINLINE BrotliErrorCode DecodeVarLenUint8(BrotliState* s,
|
||||
return BROTLI_SUCCESS;
|
||||
|
||||
default:
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE_1);
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ static BrotliErrorCode BROTLI_NOINLINE DecodeMetaBlockLength(
|
||||
return BROTLI_SUCCESS;
|
||||
|
||||
default:
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE_2);
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -786,7 +786,7 @@ Complex: /* Decode Huffman-coded code lengths. */
|
||||
}
|
||||
|
||||
default:
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE_3);
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1019,7 +1019,7 @@ rleCode:
|
||||
return BROTLI_SUCCESS;
|
||||
}
|
||||
default:
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE_4);
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1546,7 +1546,7 @@ static BROTLI_INLINE BrotliErrorCode ProcessCommandsInternal(int safe,
|
||||
} else if (s->state == BROTLI_STATE_COMMAND_POST_WRAP_COPY) {
|
||||
goto CommandPostWrapCopy;
|
||||
} else {
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE_5);
|
||||
return BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE);
|
||||
}
|
||||
|
||||
CommandBegin:
|
||||
@ -2141,7 +2141,7 @@ BrotliResult BrotliDecompressStream(size_t* available_in,
|
||||
break;
|
||||
default:
|
||||
return SaveErrorCode(s,
|
||||
BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE_6));
|
||||
BROTLI_FAILURE(BROTLI_ERROR_UNREACHABLE));
|
||||
}
|
||||
result = HuffmanTreeGroupDecode(hgroup, s);
|
||||
}
|
||||
@ -2245,6 +2245,18 @@ BrotliErrorCode BrotliGetErrorCode(const BrotliState* s) {
|
||||
return (BrotliErrorCode)s->error_code;
|
||||
}
|
||||
|
||||
const char* BrotliErrorString(BrotliErrorCode c) {
|
||||
switch (c) {
|
||||
#define _BROTLI_ERROR_CODE_CASE(PREFIX, NAME, CODE) \
|
||||
case BROTLI ## PREFIX ## NAME: return #NAME;
|
||||
#define _BROTLI_NOTHING
|
||||
BROTLI_ERROR_CODES_LIST(_BROTLI_ERROR_CODE_CASE, _BROTLI_NOTHING)
|
||||
#undef _BROTLI_ERROR_CODE_CASE
|
||||
#undef _BROTLI_NOTHING
|
||||
default: return "INVALID";
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
101
dec/decode.h
101
dec/decode.h
@ -28,60 +28,56 @@ typedef enum {
|
||||
BROTLI_RESULT_NEEDS_MORE_OUTPUT = 3
|
||||
} BrotliResult;
|
||||
|
||||
#define BROTLI_ERROR_CODES_LIST(BROTLI_ERROR_CODE, SEPARATOR) \
|
||||
BROTLI_ERROR_CODE(BROTLI_NO_ERROR, 0) SEPARATOR \
|
||||
/* Same as BrotliResult values */ \
|
||||
BROTLI_ERROR_CODE(BROTLI_SUCCESS, 1) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_NEEDS_MORE_INPUT, 2) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_NEEDS_MORE_OUTPUT, 3) SEPARATOR \
|
||||
\
|
||||
/* Errors caused by invalid input */ \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_EXUBERANT_NIBBLE, -1) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_RESERVED, -2) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_EXUBERANT_META_NIBBLE, -3) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET, -4) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME, -5) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_CL_SPACE, -6) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_HUFFMAN_SPACE, -7) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_CONTEXT_MAP_REPEAT, -8) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_BLOCK_LENGTH_1, -9) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_BLOCK_LENGTH_2, -10) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_TRANSFORM, -11) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_DICTIONARY, -12) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_WINDOW_BITS, -13) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_PADDING_1, -14) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_FORMAT_PADDING_2, -15) SEPARATOR \
|
||||
\
|
||||
/* -16..-20 codes are reserved */ \
|
||||
\
|
||||
/* Memory allocation problems */ \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_ALLOC_CONTEXT_MODES, -21) SEPARATOR \
|
||||
/* Literal, insert and distance trees together */ \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_ALLOC_TREE_GROUPS, -22) SEPARATOR \
|
||||
/* -23..-24 codes are reserved for distinct tree groups */ \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_ALLOC_CONTEXT_MAP, -25) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_ALLOC_RING_BUFFER_1, -26) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_ALLOC_RING_BUFFER_2, -27) SEPARATOR \
|
||||
/* -28..-29 codes are reserved for dynamic ringbuffer allocation */ \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_ALLOC_BLOCK_TYPE_TREES, -30) SEPARATOR \
|
||||
\
|
||||
/* "Impossible" states */ \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_UNREACHABLE_1, -31) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_UNREACHABLE_2, -32) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_UNREACHABLE_3, -33) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_UNREACHABLE_4, -34) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_UNREACHABLE_5, -35) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(BROTLI_ERROR_UNREACHABLE_6, -36)
|
||||
#define BROTLI_ERROR_CODES_LIST(BROTLI_ERROR_CODE, SEPARATOR) \
|
||||
BROTLI_ERROR_CODE(_, NO_ERROR, 0) SEPARATOR \
|
||||
/* Same as BrotliResult values */ \
|
||||
BROTLI_ERROR_CODE(_, SUCCESS, 1) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_, NEEDS_MORE_INPUT, 2) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_, NEEDS_MORE_OUTPUT, 3) SEPARATOR \
|
||||
\
|
||||
/* Errors caused by invalid input */ \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_NIBBLE, -1) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, RESERVED, -2) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_META_NIBBLE, -3) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_ALPHABET, -4) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_SAME, -5) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, CL_SPACE, -6) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, HUFFMAN_SPACE, -7) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, CONTEXT_MAP_REPEAT, -8) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_1, -9) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_2, -10) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, TRANSFORM, -11) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, DICTIONARY, -12) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, WINDOW_BITS, -13) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_1, -14) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_2, -15) SEPARATOR \
|
||||
\
|
||||
/* -16..-20 codes are reserved */ \
|
||||
\
|
||||
/* Memory allocation problems */ \
|
||||
BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MODES, -21) SEPARATOR \
|
||||
/* Literal, insert and distance trees together */ \
|
||||
BROTLI_ERROR_CODE(_ERROR_ALLOC_, TREE_GROUPS, -22) SEPARATOR \
|
||||
/* -23..-24 codes are reserved for distinct tree groups */ \
|
||||
BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MAP, -25) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_1, -26) SEPARATOR \
|
||||
BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_2, -27) SEPARATOR \
|
||||
/* -28..-29 codes are reserved for dynamic ringbuffer allocation */ \
|
||||
BROTLI_ERROR_CODE(_ERROR_ALLOC_, BLOCK_TYPE_TREES, -30) SEPARATOR \
|
||||
\
|
||||
/* "Impossible" states */ \
|
||||
BROTLI_ERROR_CODE(_ERROR_, UNREACHABLE, -31)
|
||||
|
||||
typedef enum {
|
||||
#define _BROTLI_COMMA /**/,
|
||||
#define _BROTLI_ERROR_CODE_ENUM_ITEM(NAME, CODE) NAME = CODE
|
||||
#define _BROTLI_COMMA ,
|
||||
#define _BROTLI_ERROR_CODE_ENUM_ITEM(PREFIX, NAME, CODE) \
|
||||
BROTLI ## PREFIX ## NAME = CODE
|
||||
BROTLI_ERROR_CODES_LIST(_BROTLI_ERROR_CODE_ENUM_ITEM, _BROTLI_COMMA)
|
||||
#undef _BROTLI_ERROR_CODE_ENUM_ITEM
|
||||
#undef _BROTLI_COMMA
|
||||
} BrotliErrorCode;
|
||||
|
||||
#define BROTLI_LAST_ERROR_CODE BROTLI_ERROR_UNREACHABLE_6
|
||||
#define BROTLI_LAST_ERROR_CODE BROTLI_ERROR_UNREACHABLE
|
||||
|
||||
/* Creates the instance of BrotliState and initializes it. |alloc_func| and
|
||||
|free_func| MUST be both zero or both non-zero. In the case they are both
|
||||
@ -157,16 +153,7 @@ int BrotliStateIsStreamEnd(const BrotliState* s);
|
||||
BROTLI_RESULT_ERROR. */
|
||||
BrotliErrorCode BrotliGetErrorCode(const BrotliState* s);
|
||||
|
||||
static const char* BrotliErrorString(BrotliErrorCode c) {
|
||||
switch (c) {
|
||||
#define _BROTLI_ERROR_CODE_CASE(NAME, CODE) case NAME: return #NAME;
|
||||
#define _BROTLI_NOTHING
|
||||
BROTLI_ERROR_CODES_LIST(_BROTLI_ERROR_CODE_CASE, _BROTLI_NOTHING)
|
||||
#undef _BROTLI_ERROR_CODE_CASE
|
||||
#undef _BROTLI_NOTHING
|
||||
default: return "INVALID BrotliErrorCode";
|
||||
}
|
||||
}
|
||||
const char* BrotliErrorString(BrotliErrorCode c);
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
} /* extern "C" */
|
||||
|
Loading…
Reference in New Issue
Block a user