Skip to content

Change mbedtls_platform_context parameter to NULL #199

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

Merged
merged 1 commit into from
Oct 31, 2018

Conversation

RonEld
Copy link
Contributor

@RonEld RonEld commented Sep 3, 2018

mbedtls_platform_setup() and mbedtls_platform_teardown() now ignore the context parameter, since ARMmbed/mbed-os#7099 was merged. Changing the sent parameter to NULL, to avoid misleading.

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Merging this needs to wait until the examples use Mbed OS 5.10.

int exit_code = MBEDTLS_EXIT_FAILURE;

if((exit_code = mbedtls_platform_setup(&platform_ctx)) != 0) {
if((exit_code = mbedtls_platform_setup(NULL)) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is assigning an error code from mbedtls_platform_setup() to an exit_code used to exit main(). They are two different sets of values - and the error values don't map to valid exit codes. Initialise exit_code to MBEDTLS_EXIT_SUCCESS and remove these follow on assignments. They're not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbutcher-arm I disagree.
Although the exit code is not the return code of the functions, we use it for logging the error code. When we exit the application upon failure, the return code will always be MBEDTLS_EXIT_FAILURE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I disagree. ;) I think it's reusing the variable for two different purposes with sets of values that don't necessarily mix. But it's a pre-existing problem, so I think I can ignore it for the moment, as the code works, just doesn't match my expectations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I created #205 to track this

int exit_code = MBEDTLS_EXIT_FAILURE;

if((exit_code = mbedtls_platform_setup(&platform_ctx)) != 0) {
if((exit_code = mbedtls_platform_setup(NULL)) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I think you should remove the assignment to exit_code, and initialise it to MBEDTLS_EXIT_SUCCESS instead.

int exit_code = MBEDTLS_EXIT_FAILURE;

if((exit_code = mbedtls_platform_setup(&platform_ctx)) != 0) {
if((exit_code = mbedtls_platform_setup(NULL)) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same review comment as before - remove the assignment toexit_code, and initialise it to MBEDTLS_EXIT_SUCCESS instead.

int exit_code = MBEDTLS_EXIT_FAILURE;

if((exit_code = mbedtls_platform_setup(&platform_ctx)) != 0) {
if((exit_code = mbedtls_platform_setup(NULL)) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above - remove the assignment to exit_code.

@RonEld
Copy link
Contributor Author

RonEld commented Sep 12, 2018

@sbutcher-arm I answered your comment.
I think it is good to assign the exit_code with the error codes, as it is helpful in the logging of the errors.
Upon failure, the applications return MBEDTLS_EXIT_FAILURE

Copy link
Contributor

@k-stachowiak k-stachowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think reusing the exit_code variable for storing Mbed TLS API error codes is a perfect approach, but the programs are small enough for it not to be confusing, and the code looks correct to me, therefore I approve the PR.

@RonEld
Copy link
Contributor Author

RonEld commented Sep 13, 2018

@k-stachowiak I agree that perhaps it's not the best approach, however I think that having a new variable (ret) just for the sake of logging is redundant

@simonbutcher
Copy link
Contributor

@RonEld - Can you please rebase this and resolve the conflicts?

@RonEld
Copy link
Contributor Author

RonEld commented Oct 10, 2018

@sbutcher-arm I have rebased to resolve the conflicts

@simonbutcher
Copy link
Contributor

retest

@simonbutcher
Copy link
Contributor

@RonEld - I hate to ask - but can you please rebase?

`mbedtls_platform_setup()` and `mbedtls_platform_teardown()` now ignore the context parameter, since #mbed-os/7099 was merged. Changing the sent parameter to NULL, to avoid misleading.
@RonEld RonEld force-pushed the set_NULL_as_platform_context branch from d47269d to 9fff2bb Compare October 18, 2018 12:00
@RonEld
Copy link
Contributor Author

RonEld commented Oct 18, 2018

@sbutcher-arm Done. Please review

@simonbutcher
Copy link
Contributor

retest

@simonbutcher
Copy link
Contributor

CI is failing, but only with known issues (of which we have far too many!), so this can be merged.

@simonbutcher simonbutcher merged commit 1157b14 into ARMmbed:master Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants