Tom Rini <tr...@konsulko.com> 於 2025年4月29日 週二 上午1:24寫道: > > On Mon, Apr 28, 2025 at 02:07:57PM +0800, Aristo Chen wrote: > > > Currently, when decompressing a gzip-compressed image during bootm, a > > generic error such as "inflate() returned -5" is shown when the buffer is > > too small. However, it is not immediately clear that this is caused by > > CONFIG_SYS_BOOTM_LEN being too small. > > > > This patch improves error handling by: > > - Detecting Z_BUF_ERROR (-5) returned from the inflate() call > > - Suggesting the user to increase CONFIG_SYS_BOOTM_LEN when applicable > > - Preserving the original return code from zunzip() instead of overwriting > > it with -1 > > > > By providing clearer hints when decompression fails due to insufficient > > buffer size, this change helps users diagnose and fix boot failures more > > easily. > > > > Signed-off-by: Aristo Chen <aristo.c...@canonical.com> > > I like the concept but: > > > @@ -573,12 +574,26 @@ static int handle_decomp_error(int comp_type, size_t > > uncomp_size, > > size_t buf_size, int ret) > > { > > const char *name = genimg_get_comp_name(comp_type); > > + bool likely_buf_too_small = false; > > > > /* ENOSYS means unimplemented compression type, don't reset. */ > > if (ret == -ENOSYS) > > return BOOTM_ERR_UNIMPLEMENTED; > > > > + switch (comp_type) { > > + case IH_COMP_GZIP: > > + if (ret == Z_BUF_ERROR) /* -5 */ > > + likely_buf_too_small = true; > > + break; > > + // Add more if necessary > > + default: > > + break; > > + } > > + > > if (uncomp_size >= buf_size) > > + likely_buf_too_small = true; > > + > > + if (likely_buf_too_small) > > printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n"); > > else > > printf("%s: uncompress error %d\n", name, ret); > > This is a lot of code, why not just: > if (comp_type == IH_COMP_GZIP && ret == Z_BUF_ERROR) > printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n"); > Thanks for your suggestion! I am not sure if I get it correctly, do you mean that we should remove the original if condition( if (uncomp_size >= buf_size) ) that prints the error message?
> And we can expand the tests for other algorithms either later or in > follow-up. Thanks! > > -- > Tom