Re: [PATCH RFC 1/8] staging: apfs: init lzfse compression library for APFS

Dan Carpenter
2025-03-15T09:41:50Z

On Fri, Mar 14, 2025 at 05:57:47PM -0400, Ethan Carter Edwards wrote:
> +static size_t lzfse_decode_buffer_with_scratch(uint8_t *__restrict dst_buffer,
> + size_t dst_size, const uint8_t *__restrict src_buffer,
> + size_t src_size, void *__restrict scratch_buffer) {
> + int status;
> + lzfse_decoder_state *s = (lzfse_decoder_state *)scratch_buffer;
> + memset(s, 0x00, sizeof(*s));
> +
> + // Initialize state
> + s->src = src_buffer;
> + s->src_begin = src_buffer;
> + s->src_end = s->src + src_size;
> + s->dst = dst_buffer;
> + s->dst_begin = dst_buffer;
> + s->dst_end = dst_buffer + dst_size;
> +
> + // Decode
> + status = lzfse_decode(s);
> + if (status == LZFSE_STATUS_DST_FULL)
> + return dst_size;
> + if (status != LZFSE_STATUS_OK)
> + return 0; // failed
> + return (size_t)(s->dst - dst_buffer); // bytes written
> +}

You'd be better off doing a reformat of the white space before sending
the driver. The really basic stuff.

regards,
dan carpenter