intel / isa-l

Intelligent Storage Acceleration Library
Other
946 stars 300 forks source link

Is this condition correct? #253

Closed Apollo3zehn closed 1 year ago

Apollo3zehn commented 1 year ago

I think the following line from function compress_file()

https://github.com/intel/isa-l/blob/e53db8563180712ec5f1759ec9d52b844c86fa30/programs/igzip_cli.c#L779

should actually be:

... || stream.avail_out != 0); 

(The condition is now != instead of ==).

And I would say the same applies to the function decompress_file():

https://github.com/intel/isa-l/blob/e53db8563180712ec5f1759ec9d52b844c86fa30/programs/igzip_cli.c#L943

With the original condition (avail_out == 0), the loop continues to run without being able to progress because the output buffer is full.

pablodelara commented 1 year ago

@Apollo3zehn, I think the condition is OK. At that point, avail_out indicates how many byte are still available to be written in the output (so basically, it indicates if the output buffer has been totally used). But the buffer is used again in the next iteration (see lines 763-764), as avail_out is set to outbuf_size again. So basically this condition is useful in case the input file has been fully read, but there might be some bytes left to write because all bytes in output buffer have been written. Hope this is understood.

pablodelara commented 1 year ago

Closing this issue. Feel free to open it if you think there is still an issue, thanks.

Apollo3zehn commented 1 year ago

Thank you, I understand now. The condition make sense if the buffer is being reused or resized to hold more data.