-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make warnings treated as errors for dispatch.c and protect.c #712
Make warnings treated as errors for dispatch.c and protect.c #712
Conversation
This follows an advise given by David Keller, to replace a unittest to ensure correct version of strerror_r is used. Quote: I'm afraid the strerror(EBADF) can also produce Bad file number depending on the libc (e.g. Android libc vs Glibc). If I were you, I'd remove the strerror_r() unit test as the new code will trigger a warning if the wrong strerror_r() is picked (invalid conversion from int to char*: warning: initialization makes pointer from integer without a cast) and treat warnings as errors with -Werror.
c2bcf53
to
87606cc
Compare
@DavidKeller could you please have a look at this? The basic idea is, that I did not want to touch the build of libffi, but only affect the build of the JNA specific parts. I had to fix/suppress some warnings:
Do the changes look sane to you? |
Hello @matthiasblaesing,
Sure.
Your change seems fine.
Replacing the
But the original code (and my proposal) seems undefined behavior to me:
Thread local variables will help but at what cost ?
As a general rule, I believe it's better to correct warnings instead of silencing it when possible :-) Here you can work around using a dedicated function with a non-reserved C standard name and use it everywhere.
Regards |
"Protected mode" (setjmp/longjmp) was only intended to be used in a single On Mon, Oct 3, 2016 at 11:33 AM, David Keller [email protected]
|
As the protected mode is optional, is the cost implied by thread local jmp_buf (on *nix) acceptable for you ? |
Nominally that'd be ok, but I think when I originally did this there was On Tue, Oct 4, 2016 at 12:07 PM, David Keller [email protected]
|
On Linux :
As you said, there is no cross-platform guarantee (i.e. POSIX) on threads, hence I agree that using thread local wouldn't provide any real guarantee. I suspect this is a grey area where there is no standard way to recover from |
f3d9bd3
to
c07db9a
Compare
Thank you David and Timothy for the feedback and discussion. From the raised pointers:
I pushed a new revision with the described changes. This stage is tested as follows:
|
This follows an advise given by David Keller, to replace a unittest
to ensure correct version of strerror_r is used.
Quote:
I'm afraid the strerror(EBADF) can also produce Bad file number
depending on the libc (e.g. Android libc vs Glibc).
If I were you, I'd remove the strerror_r() unit test as the new code
will trigger a warning if the wrong strerror_r() is picked (invalid
conversion from int to char*: warning: initialization makes pointer
from integer without a cast) and treat warnings as errors with -Werror.