[riot-notifications] [RIOT-OS/RIOT] cpu/esp32/freertos: fix semaphore take (#11239)

Gunar Schorcht notifications at github.com
Tue Jul 30 20:32:47 CEST 2019


gschorcht commented on this pull request.



> @@ -94,7 +94,7 @@ BaseType_t xSemaphoreTake (SemaphoreHandle_t xSemaphore,
         case queueQUEUE_TYPE_MUTEX:
         {
             if (xTicksToWait == 0) {
-                return (mutex_trylock(mutex) == 0) ? pdTRUE : pdFALSE;
+                return (mutex_trylock(mutex) == 1) ? pdPASS : pdFAIL;

This might become a pitfall. By default these are defined:
```
#define errQUEUE_EMPTY ( ( BaseType_t ) 0 )
#define pdFALSE        ( ( BaseType_t ) 0 )
#define pdFAIL         ( pdFALSE )
```
Defining something like an error code which is nothing else or the same as `pdFALSE` is quite strange, especially since other error codes are real values
```
#define errQUEUE_BLOCKED    ( -4 )
#define errQUEUE_YIELD      ( -5 )
```
If someone concludes from the online documentation that `xSemaphoreTake` returns something like a boolean, he could try the following:
```
if (!xSemaphoreTake(...)) {
    ...
}
```
Although it would work for `errQUEUE_EMPTY` but not for the other error codes.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11239#discussion_r308876814
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190730/78422f27/attachment.htm>


More information about the notifications mailing list