openSUSE / libsolv

Library for solving packages and reading repositories
http://en.opensuse.org/openSUSE:Libzypp_satsolver
Other
509 stars 151 forks source link

Report unsupported compression in solv_xfopen() with errno #563

Closed ppisar closed 1 month ago

ppisar commented 1 month ago

If libsolv was built without Zstandard support and "primary.xml.zst" was passed solv_xfopen(), solv_xfopen() returned 0 without setting errno. A calling application could not distinguish an unsupported compression format from other I/O errors.

This patch improves this situation by setting errno variable to an appropriate value.

mlschroe commented 1 month ago

Is ENOTSUP available everywhere? I.e. on BSD and windows (MSVC)?

(You can also use solv_xfopen_iscompressed() to figure out if the compression is supported: it returns 0 if the file is not compressed, 1 if it is compressed and the compression is supported, or -1 if the compression is not supported.)

ppisar commented 1 month ago

I have no idea. Do people process YUM repositories on BSD or Windows?

ppisar commented 1 month ago

ENOTSUP is documented in POSIX 2017 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html.

Conan-Kudo commented 1 month ago

I have no idea. Do people process YUM repositories on BSD or Windows?

Yes. But also this is not YUM-only.

ppisar commented 1 month ago

Ok. I will add a #ifdef guard.

ppisar commented 1 month ago

Now the code should compile even if ENOTSUP is not available.

mlschroe commented 1 month ago

I think if it's in POSIX we don't need the guard. If somebody complains that it's missing for some specific OS, we can add a

#ifndef ENOTSUP
#define ENOTSUP <something_else>
#endif

at the beginning...

ppisar commented 1 month ago

I removed the guards.

mlschroe commented 1 month ago

Thanks!