lib/lz4/lz4_decompress.c
Source file repositories/reference/linux-study-clean/lib/lz4/lz4_decompress.c
File Facts
- System
- Linux kernel
- Corpus path
lib/lz4/lz4_decompress.c- Extension
.c- Size
- 20935 bytes
- Lines
- 720
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
lz4defs.hlinux/init.hlinux/module.hlinux/kernel.hlinux/unaligned.h
Detected Declarations
function LZ4_decompress_genericfunction shortcutfunction LZ4_decompress_safefunction LZ4_decompress_safe_partialfunction LZ4_decompress_fastfunction LZ4_decompress_safe_withPrefix64kfunction LZ4_decompress_safe_withSmallPrefixfunction LZ4_decompress_safe_forceExtDictfunction LZ4_decompress_fast_extDictfunction LZ4_decompress_safe_doubleDictfunction LZ4_decompress_fast_doubleDictfunction LZ4_setStreamDecodefunction LZ4_setStreamDecodefunction LZ4_decompress_fast_continuefunction LZ4_decompress_safe_usingDictfunction LZ4_decompress_fast_usingDictexport LZ4_decompress_safeexport LZ4_decompress_safe_partialexport LZ4_decompress_fastexport LZ4_setStreamDecodeexport LZ4_decompress_safe_continueexport LZ4_decompress_fast_continueexport LZ4_decompress_safe_usingDictexport LZ4_decompress_fast_usingDict
Annotated Snippet
if (length == RUN_MASK) {
unsigned int s;
if (unlikely(endOnInput ? ip >= iend - RUN_MASK : 0)) {
/* overflow detection */
goto _output_error;
}
do {
s = *ip++;
length += s;
} while (likely(endOnInput
? ip < iend - RUN_MASK
: 1) & (s == 255));
if ((safeDecode)
&& unlikely((uptrval)(op) +
length < (uptrval)(op))) {
/* overflow detection */
goto _output_error;
}
if ((safeDecode)
&& unlikely((uptrval)(ip) +
length < (uptrval)(ip))) {
/* overflow detection */
goto _output_error;
}
}
/* copy literals */
cpy = op + length;
LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
if (((endOnInput) && ((cpy > oend - MFLIMIT)
|| (ip + length > iend - (2 + 1 + LASTLITERALS))))
|| ((!endOnInput) && (cpy > oend - WILDCOPYLENGTH))) {
if (partialDecoding) {
if (cpy > oend) {
/*
* Partial decoding :
* stop in the middle of literal segment
*/
cpy = oend;
length = oend - op;
}
if ((endOnInput)
&& (ip + length > iend)) {
/*
* Error :
* read attempt beyond
* end of input buffer
*/
goto _output_error;
}
} else {
if ((!endOnInput)
&& (cpy != oend)) {
/*
* Error :
* block decoding must
* stop exactly there
*/
goto _output_error;
}
if ((endOnInput)
&& ((ip + length != iend)
|| (cpy > oend))) {
/*
* Error :
* input must be consumed
*/
goto _output_error;
}
}
/*
* supports overlapping memory regions; only matters
* for in-place decompression scenarios
*/
LZ4_memmove(op, ip, length);
ip += length;
op += length;
/* Necessarily EOF when !partialDecoding.
* When partialDecoding, it is EOF if we've either
* filled the output buffer or
* can't proceed with reading an offset for following match.
*/
if (!partialDecoding || (cpy == oend) || (ip >= (iend - 2)))
break;
} else {
Annotation
- Immediate include surface: `lz4defs.h`, `linux/init.h`, `linux/module.h`, `linux/kernel.h`, `linux/unaligned.h`.
- Detected declarations: `function LZ4_decompress_generic`, `function shortcut`, `function LZ4_decompress_safe`, `function LZ4_decompress_safe_partial`, `function LZ4_decompress_fast`, `function LZ4_decompress_safe_withPrefix64k`, `function LZ4_decompress_safe_withSmallPrefix`, `function LZ4_decompress_safe_forceExtDict`, `function LZ4_decompress_fast_extDict`, `function LZ4_decompress_safe_doubleDict`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.