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

sslConfig_create didn't return a pointer #22

Closed
clearday4 opened this issue Aug 12, 2020 · 4 comments · Fixed by #27
Closed

sslConfig_create didn't return a pointer #22

clearday4 opened this issue Aug 12, 2020 · 4 comments · Fixed by #27

Comments

@clearday4
Copy link

sslConfig_create() is not void function but not return a sslConfig pointer.
Need to add return sslConfig.

@ityuhui
Copy link
Member

ityuhui commented Aug 13, 2020

Hi @clearday4

Thank you for your finding ! You're right, the function should return sslConfig

sslConfig_t *sslConfig_create(const char *clientCertFile, const char *clientKeyFile, const char *CACertFile, int insecureSkipTlsVerify) {
    sslConfig_t *sslConfig = calloc(1, sizeof(sslConfig_t));
    if ( clientCertFile ) {
        sslConfig->clientCertFile = strdup(clientCertFile);
    }
    if ( clientKeyFile ) {
        sslConfig->clientKeyFile = strdup(clientKeyFile);
    }
    if ( CACertFile ) {
        sslConfig->CACertFile = strdup(CACertFile);
    }
    sslConfig->insecureSkipTlsVerify = insecureSkipTlsVerify;
    <== YessslConfig shoud be returned here. It's my fault.
}

I have not found this issue before because the sslConfig is returned to caller actually. Maybe the compiler/gcc handles this defect and returns the sslConfig automatically. So this defect has no impact on gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04).

But anyway, this defect should be fixed. I will handle it some times later. If anyone has interest, the fix should be done in the project OpenAPI-Generator/c

Thank you.

@brendandburns
Copy link
Contributor

I suspect that this is because of x86 conventions and the pointer being stored in the same register as the expected return value:

https://stackoverflow.com/questions/7280877/why-and-how-does-gcc-compile-a-function-with-a-missing-return-statement

but we should definitely fix this.

@brendandburns
Copy link
Contributor

I filed:
OpenAPITools/openapi-generator#7217

in the generator to fix this.

@brendandburns
Copy link
Contributor

The code generator patch is merged (though there are other issues that were detected)

We should fix the other issues, and then regenerate.

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 a pull request may close this issue.

3 participants