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

Platform_lock_request return value not evaluated #61

Open
pahaseag opened this issue Sep 15, 2022 · 1 comment
Open

Platform_lock_request return value not evaluated #61

pahaseag opened this issue Sep 15, 2022 · 1 comment
Assignees

Comments

@pahaseag
Copy link

The platform_lock_request() function returns a bool. The desired behaviour regarding the return value is not described in the platform.h file but looking at the linux implementation, false is returned when no lock can be aquired (see https://github.com/wirepas/c-mesh-api/blob/master/lib/platform/linux/platform.c#L245).

However, in the API (wpc) the return value of Platform_lock_request() is never checked, e.g. see here https://github.com/wirepas/c-mesh-api/blob/master/lib/wpc/wpc_internal.c#L332. In the mentioned example the code after Platform_lock_request() is executed even if no lock can be acquired.
The callers of the Platform_lock_request() are mostly located in the functionality and are not intended to be changed by a user/customer.
Should the return value of Platform_lock_request() not be evaluated and corresponding actions implemented if the lock can not be acquired?

@GwendalRaoul
Copy link
Contributor

Hello,

Thanks for the feedback.
Yes you are correct, the code is ambiguous (and a bit wrong ;-) )

In the code, we always assume that platform_lock_request() return successfully. It can of course block the calling thread, but it should never returned without the lock being acquired (as mention in the Linux implementation it should never happen)

But in other platform in may be a bit harder to ensure.

I quickly checked the different places where it is called and it shouldn't be a big deal to handle the case where false is returned (ie propagate the error).

That being said, if it happens there is probably a problem in the design.

Best regards,
Gwendal

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

No branches or pull requests

2 participants