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
Write to stderr in ParseAPI::parsing_printf #1650
Conversation
Using a per-thread file here is cumbersome. Including the thread id in the message and synchronizing vprintf makes this work for multiple threads.
This is a contentious warning that was added to clang-15. See (https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734/85) for details. Disable it for now. This should be converted to a standard diagnostic suppression in common/compiler_diagnostics.h.
That was an inadvertent change.
parseAPI/src/debug_parse.C
Outdated
#pragma omp critical | ||
{ | ||
v = fprintf(stderr, "[thread %d] ", id); | ||
v &= vfprintf(stderr, format, va); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The &=
doesn't make sense. fprintf returns the number of characters written or -1 on error. You should record each return value separately in r1
and r2
with a return value of r1 != -1 && r2 != -1) ? (r1 + r2) : -1
. Slightly better would be to also only execute the second vprintf
if r1 != -1
. It is also likely that nothing looks at the return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slight change in error handling.
Using a per-thread file here is cumbersome. Including the thread id in the message and synchronizing vprintf makes this work for multiple threads.