-
Notifications
You must be signed in to change notification settings - Fork 251
Add and use eprintf() and strerrno(), and de-weirdify SYSLOG(()) #1289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I recommend reviewing the second commit with $ git show HEAD^ --color-words=. |
5fa8f9a
to
c3af808
Compare
I have some reservations about commits 1 and 2. Specifically, the new interface introduced isn't something I've commonly seen in other projects, even though I'm aware of its mention in the GCC documentation. From my perspective, it doesn't appear to offer a significant benefit here. Furthermore, I'm concerned that commit 2 introduces changes across many files, which could make it quite challenging for distribution maintainers to backport future changes to their distributions. This could lead to a lot of friction and messy patch applications down the line. On the other hand, I'm fine with the changes in commits 3 and 4. They look good to me. |
Yeah, I guess this would be a lot of work for distros. I'm fine not applying it for now; we can come back to it in the future.
I will split patches 3 and 4 to allow applying them separately. |
c3af808
to
a3ed1da
Compare
On the other hand, I plan to do a lot of work on error messages after this eprintf() patch, trying to unify them and use But yeah, we have lower hanging fruits for now. |
a3ed1da
to
13a8030
Compare
I think we now have strong reasons to merge this. See the bug fixed in a call to SYSLOG() (and fprintf()). Edit: I've found more bugs after spending more time looking at these calls. |
97d7478
to
68dfb3a
Compare
55cd6cb
to
0a20d7b
Compare
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]>
Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
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]>
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]>
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]>
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]>
0a20d7b
to
3b1b87e
Compare
This allows compacting a lot of code. It also makes it easier to discern lines that print to actual files, from those that print to stderr/stdout.
Revisions:
v2
#include "config.h"
with quotes.v2b
v3
v4
v5
v5b
v6
v6b
v6c
v6d
v6e
v6f
v6g
v7