TLS: Correct handling of returned error values.

I not two problems in handling of the return error values in PR #3858:

1. In KERNEL mode, the error return value of _SEM_WAIT() will be a negated errno value; in all other modes, it will be -1 (ERROR) with the errno variable set.  This must be handled in the test of the returned value:  Don't compare with -1; rather check if < 0
2. Also, conversion of the returned value to a negated errno value must be handled differently.  This is handled by replacing -get_errno() with the macro _ERRVAL(ret)

This effects only error handling (it fixes it) and no other impacts are expected.
This commit is contained in:
Gregory Nutt
2021-06-07 22:32:42 -03:00
committed by Gustavo Henrique Nihei
parent 3859031a6b
commit 9aaeaefa41
2 changed files with 3 additions and 4 deletions
+2 -3
View File
@@ -66,10 +66,9 @@ int tls_alloc(void)
*/
ret = _SEM_WAIT(&tinfo->ta_tlssem);
if (ERROR == ret)
if (ret < 0)
{
ret = -get_errno();
ret = _SEM_ERRVAL(ret);
goto errout_with_errno;
}
+1 -1
View File
@@ -79,7 +79,7 @@ int tls_free(int tlsindex)
}
else
{
ret = -get_errno();
ret = _SEM_ERRVAL(ret);
}
}