From a0df376348d2ad1d3e557ea221e75c78a5d9fd96 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Dec 2022 12:12:05 +0100 Subject: pkg/image: make Decompress easier to use Change DecompressWriter to DecompressCheck: checking validity of the image is the only useful use of DecompressWriter. Change Decompress to MustDecompress which does not return an error. We check validity during program deserialization, so all other uses already panic on errors. Also add dtor return value in preparation for subsequent changes. --- prog/analysis.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'prog/analysis.go') diff --git a/prog/analysis.go b/prog/analysis.go index fec43e1bd..850fdb1dd 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -356,10 +356,8 @@ func (p *Prog) ForEachAsset(cb func(name string, typ AssetType, r io.Reader)) { if !ok || a.Type().(*BufferType).Kind != BufferCompressed { return } - data, err := image.Decompress(a.Data()) - if err != nil { - panic(err) - } + data, dtor := image.MustDecompress(a.Data()) + defer dtor() if len(data) == 0 { return } -- cgit mrf-deployment