Skip to content

Commit

Permalink
thread/mtx_alloc: use c11 return enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Jul 12, 2022
1 parent b38512c commit a5a79c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/re_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void tss_delete(tss_t key);
*
* @param mtx Pointer to new mutex
*
* @return 0 if success, otherwise errorcode
* @return thrd_success on success, otherwise thrd_error or thrd_nomem
*/
int mtx_alloc(mtx_t **mtx);

Expand Down
8 changes: 3 additions & 5 deletions src/thread/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ int mtx_alloc(mtx_t **mtx)
int err;

if (!mtx)
return EINVAL;
return thrd_error;

m = mem_alloc(sizeof(mtx_t), NULL);
if (!m)
return ENOMEM;
return thrd_nomem;

err = mtx_init(m, mtx_plain);
if (err == thrd_error) {
err = EBUSY;
if (err != thrd_success)
goto out;
}

mem_destructor(m, mtx_destructor);

Expand Down

0 comments on commit a5a79c3

Please sign in to comment.