You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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.
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?
The text was updated successfully, but these errors were encountered: