Skip to content

capture-libs: Use warnx() instead of warn() when errno is not set

Simon McVittie requested to merge wip/smcv/warnx into master

warn(fmt, args) is equivalent to (pseudocode) warnx(fmt + ": %s", args, strerror(errno)). In contexts where we do not have a useful value for errno, or where we are showing an error message that should already contain a previous result of strerror, we should use warnx() instead. This avoids showing a misleading errno which might have been set for some unrelated reason.

Prompted by jupiter/tasks#887.


/cc @evelikov @denittis

This is why we saw a spurious

i386-linux-gnu-capsule-capture-libs: warning: Dependencies of libidn2.so.0 not found, ignoring: Missing dependencies: Could not find "libunistring.so.2" in LD_LIBRARY_PATH "", ld.so.cache, DT_RUNPATH, /lib or /usr/lib: Invalid argument

instead of the expected

i386-linux-gnu-capsule-capture-libs: warning: Dependencies of libidn2.so.0 not found, ignoring: Missing dependencies: Could not find "libunistring.so.2" in LD_LIBRARY_PATH "", ld.so.cache, DT_RUNPATH, /lib or /usr/lib

while investigating jupiter/tasks#887.

Merge request reports