Skip to content
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

strerror_r on cygwin #138

Closed
kubo opened this issue Jun 27, 2020 · 4 comments
Closed

strerror_r on cygwin #138

kubo opened this issue Jun 27, 2020 · 4 comments
Assignees
Labels
bug patch available Awaiting inclusion in official release

Comments

@kubo
Copy link

kubo commented Jun 27, 2020

ODPI-C version: 4.0.1
OS: Cygwin on Windows
Compiler: gcc

Cygwin declares GNU-version strerror_r when _GNU_SOURCE is defined. However the POSIX version is used in the following code.

#if defined(__GLIBC__)
    message = strerror_r(err, buffer, sizeof(buffer));
#else
    message = (strerror_r(err, buffer, sizeof(buffer)) == 0) ? buffer : NULL;
#endif

No warnings by accident when compiling ODPI-C. That's because comparison with a pointer and literal zero is compilable without warnings.

When the above code is changed as follows,

#if defined(__GLIBC__)
    message = strerror_r(err, buffer, sizeof(buffer));
#else
    int rv = strerror_r(err, buffer, sizeof(buffer));
    message = (rv == 0) ? buffer : NULL;
#endif

gcc prints the following warning.

gcc -c -Iinclude -O2 -g -Wall -Wextra -fPIC src/dpiError.c -o build/dpiError.o
src/dpiError.c: In function 'dpiError__setFromOS':
src/dpiError.c:262:14: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
     int rv = strerror_r(err, buffer, sizeof(buffer));
              ^~~~~~~~~~

This implies that the strerror_r isn't the POSIX version returning int. It is the GNU version returning char *.

The following code in place of #if defined(__GLIBC__) fixes the issue.

#if defined(__GLIBC__) || defined(__CYGWIN__)
@kubo kubo added the bug label Jun 27, 2020
@cjbj
Copy link
Member

cjbj commented Jun 27, 2020

Thanks @kubo

@anthony-tuininga
Copy link
Member

I've marked this for version 4.1 but if a patch release (4.0.2) is created I'll include it in there, too.

@anthony-tuininga
Copy link
Member

Let me know if the creation of a patch release would be helpful to you, @kubo.

@anthony-tuininga
Copy link
Member

This was included in 4.0.2 released on August 31, 2020.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug patch available Awaiting inclusion in official release
Projects
None yet
Development

No branches or pull requests

3 participants