[PATCH] lib: Make error.c more like error(3)

Mark Wielaard mark@klomp.org
Sun Sep 12 21:00:35 GMT 2021


Hi Colin,

On Fri, Sep 10, 2021 at 11:07:16AM -0700, Colin Cross via Elfutils-devel wrote:
> Fix some issues with the error reimplementation to make it match
> the specification for error(3).
> 
> Flush stdout before printing to stderr.  Also flush stderr afterwards,
> which is not specified in the man page for error(3), but is what
> bionic does.
> 
> error(3) prints strerror(errnum) if and only if errnum is nonzero,
> but verr prints strerror(errno) unconditionaly.  When errnum is nonzero
> copy it to errno and use verr, and when it is not set use verrx that
> doesn't print errno.
> 
> error(3) only exits if status is nonzero, but verr exits uncondtionally.
> Use vwarn/vwarnx when status is zero, which don't exit.
> 
> Signed-off-by: Colin Cross <ccross@google.com>

This is really nice. Thanks.  I pushed it with a ChangeLog entry and
reformatted the patch to GNU style as attached.

Note that there are still some small differences between "real" error
and our error implementation, which don't seem to matter in practice,
but do cause some testsuite failures because of silly
formatting. e.g. run-stack-i.sh fails with:

-stack: tid 13654: shown max number of frames (6, use -n 0 for unlimited)
+/home/mark/src/elfutils/src/stack: tid 13654: shown max number of frames (6, use -n 0 for unlimited)

I have not tries to fix these. The testcases probably should be
slightly less picky about the exact error message format.

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lib-Make-error.c-more-like-error-3.patch
Type: text/x-diff
Size: 2489 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20210912/9a1a2ad1/attachment.bin>


More information about the Elfutils-devel mailing list