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

Fixed memmanager and add assertion #277

Conversation

Hadatko
Copy link
Member

@Hadatko Hadatko commented May 17, 2022

assertion added for functions which are returning status on freeing memory

Signed-off-by: Cervenka Dusan cervenka@acrios.com

Pull request

Choose Correct

  • bug
  • feature

Describe the pull request

Some functions which are freeing memory are returning statuses. These should be checked.

To Reproduce

Expected behavior

Screenshots

Desktop (please complete the following information):

  • OS:
  • eRPC Version:

Steps you didn't forgot to do

  • I checked if other PR isn't solving this issue.
  • I read Contribution details and did appropriate actions.
  • PR code is tested.
  • PR code is formatted.

Additional context

assertion added for functions which are returning status on freeing memory

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
@Hadatko
Copy link
Member Author

Hadatko commented May 17, 2022

Hi @MichalPrincNXP i cannot test these changes but they should be valid. What do you think?

@amgross
Copy link
Contributor

amgross commented May 18, 2022

As I told in #275 :

  1. Asserting also on NULL pointer error makes the free function behave different than standard library free, which I think is not good idea.
  2. I will prefer flow will continue in case that free fails (at least at non debug flavors), it is just memory leak, not fatal.

Nullptr can be inserted if allocation failed. Expected state.

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
@Hadatko
Copy link
Member Author

Hadatko commented May 18, 2022

@amgross As mentioned in same PR i was expecting you will add NULL check. But here it make sense too so i did it.
Assertion are turned ON usually for debug mode and for release mode they are off. At least it should be the case MBED and MQX port. Currently Freertos implementation seems to be in both release and debug targets, but this changes is not related to it.

@amgross
Copy link
Contributor

amgross commented May 18, 2022

what about the other comments?

@Hadatko
Copy link
Member Author

Hadatko commented May 18, 2022

Which one do you mean? I don't see other comment

@amgross
Copy link
Contributor

amgross commented May 18, 2022

image

@amgross
Copy link
Contributor

amgross commented May 18, 2022

Can't you see those code review comments in the thread?

@Hadatko
Copy link
Member Author

Hadatko commented May 18, 2022

@amgross
Copy link
Contributor

amgross commented May 19, 2022

Interesting, I looked on other repository that has same functions with different inputs and return enum

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
@Hadatko
Copy link
Member Author

Hadatko commented May 19, 2022

@amgross i pushed commit to be backward compatible. What do you think?

@amgross
Copy link
Contributor

amgross commented May 19, 2022

Why do we need here backward compatibility?
Do you think someone will want to continue allocating forever?? (if yes, so you will need to remove the assert from the free I suppose because the free will fail)

Copy link
Member

@MichalPrincNXP MichalPrincNXP left a comment

Choose a reason for hiding this comment

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

Hi @Hadatko , I would remove the backward compatibility section/defines ... looking at the history of mem_manager NXP component, I am not able to find the MEM_BufferAllocForever() function (up to 2018 state). I would use MEM_BufferAllocWithId() directly.
I am also not able to verify the functionality of these two updated porting layers as these are not used in any maintained example/test.
#include "MemManager.h" should be changed to #include "fsl_component_mem_manager.h"

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
@Hadatko
Copy link
Member Author

Hadatko commented Jun 8, 2022

@MichalPrincNXP Is it ok now?

@MichalPrincNXP
Copy link
Member

@MichalPrincNXP Is it ok now?

I think so, thank you!

@MichalPrincNXP MichalPrincNXP merged commit 80d7158 into EmbeddedRPC:develop Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants