Message ID | 20210430090053.1511699-1-dominique.martinet@atmark-techno.com |
---|---|
State | Accepted |
Headers | show |
Series | cpio_utils: print human zstd error | expand |
Hi Dominique, On 30.04.21 11:00, Dominique Martinet wrote: > ZSTD errors are negative numbers, printing these as %zu is > hard to read. > Use ZSTD_getErrorName() to get an easier error > > Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> > --- > (I stumbled on this because I had regenerated an encryption key > but not sent it to device, so decompression failed -- quite annoying > that we can't detect the aes key was wrong until decrpytion is finalized > but I don't see any way around it... Right, I had also such a cases, and it becomes harder if sw-description is encrypted, too. Anyway, the behavior is correct and SWUpdate cannot distinguish between wrong key / corrupted file. > Anyway, it won't hurt to have > readable errors, "Unknown frame descriptor" is slightly better than > "returned 18446744073709551606") Of course. > > core/cpio_utils.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/core/cpio_utils.c b/core/cpio_utils.c > index b4131edc9525..67cc8055cac3 100644 > --- a/core/cpio_utils.c > +++ b/core/cpio_utils.c > @@ -364,7 +364,8 @@ static int zstd_step(void* state, void* buffer, size_t size) > decompress_ret = ZSTD_decompressStream(s->dctx, &output, &s->input_view); > > if (ZSTD_isError(decompress_ret)) { > - ERROR("ZSTD_decompressStream failed (returned %zu)", decompress_ret); > + ERROR("ZSTD_decompressStream failed: %s", > + ZSTD_getErrorName(decompress_ret)); > return -1; > } > > I push it for the release, thanks ! Best regards, Stefano Babic
diff --git a/core/cpio_utils.c b/core/cpio_utils.c index b4131edc9525..67cc8055cac3 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -364,7 +364,8 @@ static int zstd_step(void* state, void* buffer, size_t size) decompress_ret = ZSTD_decompressStream(s->dctx, &output, &s->input_view); if (ZSTD_isError(decompress_ret)) { - ERROR("ZSTD_decompressStream failed (returned %zu)", decompress_ret); + ERROR("ZSTD_decompressStream failed: %s", + ZSTD_getErrorName(decompress_ret)); return -1; }
ZSTD errors are negative numbers, printing these as %zu is hard to read. Use ZSTD_getErrorName() to get an easier error Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> --- (I stumbled on this because I had regenerated an encryption key but not sent it to device, so decompression failed -- quite annoying that we can't detect the aes key was wrong until decrpytion is finalized but I don't see any way around it... Anyway, it won't hurt to have readable errors, "Unknown frame descriptor" is slightly better than "returned 18446744073709551606") core/cpio_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)