[openssl-dev] [Suggestion] crypto/threads_win.c: Follow Consistent Return Style
Kurt Cancemi
kurt at x64architecture.com
Sun May 8 07:52:20 UTC 2016
Every function that returns an int in crypto/threads_win.c returns 0
immediately if the function called from inside the function fails
except CRYPTO_THREAD_run_once() which returns 1 immediately if the
function called from inside the function succeeds.
InitOnceExecuteOnce returns 0 on failure
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683493%28v=vs.85%29.aspx
So my suggestion would be to follow this convention in
CRYPTO_THREAD_run_once() too:
--- crypto/threads_win.c 2016-05-08 03:42:44.401795919 -0400
+++ crypto/threads_win.c 2016-05-08 03:42:55.151796152 -0400
@@ -135,10 +135,10 @@
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
{
- if (InitOnceExecuteOnce(once, once_cb, init, NULL))
- return 1;
+ if (!InitOnceExecuteOnce(once, once_cb, init, NULL))
+ return 0;
- return 0;
+ return 1;
}
# endif
--
Kurt Cancemi
https://www.x64architecture.com
More information about the openssl-dev
mailing list