Skip to content

Conversation

@alejandro-colomar
Copy link
Collaborator

Queued after #1289 .

@alejandro-colomar alejandro-colomar changed the title Simplify error handling Simplify error handling (especially, error messages) Jul 26, 2025
@alejandro-colomar alejandro-colomar changed the title Simplify error handling (especially, error messages) Simplify error handling (mainly, error messages) Jul 26, 2025
Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
This will allow having shorter lines for writing to stderr.

This name is commonly used in other projects, it seems (see link below).

Link: <https://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/Variadic-Macros.html>
Signed-off-by: Alejandro Colomar <[email protected]>
The double parentheses were used to fake a variadic macro with a
non-variadic one.  With a variadic macro, we remove the weird double
parentheses that were needed to call this macro, which BTW were
error-prone (see the bug fixed in the previous commit).

Signed-off-by: Alejandro Colomar <[email protected]>
The name of this macro makes it more evident what it does.  It's a
C-locale version of syslog(3).  We need to implement it as a macro
so that arguments such as strerror(3) are evaluated after setting
the C locale.  This would be impossible with a function.

Signed-off-by: Alejandro Colomar <[email protected]>
There's no need for two variables, and this avoids one assignment.

Signed-off-by: Alejandro Colomar <[email protected]>
…nally

Both setlocale(3) and free(3) are okay to call with a null pointer.

Signed-off-by: Alejandro Colomar <[email protected]>
This function preserves errno, so that a following syslog(3) call still
has the previous errno value.

Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Having such long and complex format strings and variadic arguments is
error-prone, as can be seen in the previous commit, which fixes a bug of
this kind.

Signed-off-by: Alejandro Colomar <[email protected]>
Print simpler messages that don't need translation.
Check libc errors with ==-1 and ==NULL instead of <0 (or !=0) and !p.

Signed-off-by: Alejandro Colomar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant